How do you make a refund? What address do you send it to?

For example: What happens if I send it back to the “parent_coin_info” hash… does that tnx make it back to the sending wallet? Or the puzzle_hash? Is that possible (never tried)?

If not… how do you figure out what one of the sending wallet’s receiving addresses are?

Thanks!

Here’s what I got so far:

Command:
chia wallet get_transactions

Output:
Transaction 485d8eb7becfddd32bf0a7a75ad243c79869d05c42156c2bae94b4239c405d7f
Status: Confirmed
Amount received: 1E-9 XCH
To address: xch1j8ychtyn9r957seng2tyc99u76c3nalejjznhzlxlvke6ucvqxjqd553l2
Created at: 2022-04-22 06:05:33

Command:
chia wallet get_transactions -v

Output:
{‘additions’: [{‘amount’: 1000,
‘parent_coin_info’: ‘0xd23a44027d1d2eace95ef3896f76873ffdfaf7203992598619b62e446dedab97’,
‘puzzle_hash’: ‘0x91c98bac9328cb4f433342964c14bcf6b119f7f994853b8be6fb2d9d730c01a4’}],
‘amount’: 1000,
‘confirmed’: True,
‘confirmed_at_height’: 1871970,
‘created_at_time’: 1650607533,
‘fee_amount’: 0,
‘memos’: ,
‘name’: ‘0x485d8eb7becfddd32bf0a7a75ad243c79869d05c42156c2bae94b4239c405d7f’,
‘removals’: ,
‘sent’: 0,
‘sent_to’: ,
‘spend_bundle’: None,
‘to_puzzle_hash’: ‘0x91c98bac9328cb4f433342964c14bcf6b119f7f994853b8be6fb2d9d730c01a4’,
‘trade_id’: None,
‘type’: 0,
‘wallet_id’: 1}

Command: (output similar to above)
get_transaction -tx 9f8637de656a40b136f64ebcb146bc55fd6eb5a297b29b53a937954d783391af -v

Output:
{‘additions’: [{‘amount’: 1000,
‘parent_coin_info’: ‘0x9cafe6ce83ea11a5fd35a4cfbf658c0863c2b9d042b97b0a5049cfd2ce0d5888’,
‘puzzle_hash’: ‘0x91c98bac9328cb4f433342964c14bcf6b119f7f994853b8be6fb2d9d730c01a4’}],
‘amount’: 1000,
‘confirmed’: True,
‘confirmed_at_height’: 1871858,
‘created_at_time’: 1650605353,
‘fee_amount’: 0,
‘memos’: ,
‘name’: ‘0x9f8637de656a40b136f64ebcb146bc55fd6eb5a297b29b53a937954d783391af’,
‘removals’: ,
‘sent’: 0,
‘sent_to’: ,
‘spend_bundle’: None,
‘to_puzzle_hash’: ‘0x91c98bac9328cb4f433342964c14bcf6b119f7f994853b8be6fb2d9d730c01a4’,
‘trade_id’: None,
‘type’: 0,
‘wallet_id’: 1}

I just tried both the parent_coin_info and puzzle_hash and they both failed:

Exception from 'wallet' {'error': 'Invalid Address', 'success': False}

Some Farmer is getting a ton of my test Chia…

Ok… so I converted the puzzle hash:
cdv hash 0x9cafe6ce83ea11a5fd35a4cfbf658c0863c2b9d042b97b0a5049cfd2ce0d5888
Output:
7c1f6902c899ec06d5fdcccabafde440bac5daf1c007af78ed2f3616dab164a5

then that to an address:
Output:
xch10s0kjqkgn8kqd40aen9t4l0ygzavtkh3cqr6778d9umpdk43vjjspc23ww

I also skipped the first step and just removed the 0x
cdv encode 9cafe6ce83ea11a5fd35a4cfbf658c0863c2b9d042b97b0a5049cfd2ce0d5888

Output:
xch1njh7dn5ragg6tlf45n8m7evvpp3u9wwsg2uhkzjsf88a9nsdtzyq28v54g

Tried that several times with several hashes and not once did it get returned to my original test wallet that send the chia to my second test wallet.

To send a coin back to the puzzle it came from, you can fetch the puzzle hash from the parent coin info using the RPC get_coin_record_by_name. Or use cdv rpc coinrecords --by id 0x.... Once you have that puzzle hash, you can convert it to an address and send it there.

Thanks. Ok… so…

cdv rpc coinrecords --by id 0x9cafe6ce83ea11a5fd35a4cfbf658c0863c2b9d042b97b0a5049cfd2ce0d5888

Returns:
puzzle_hash: 0xcdd99ce61659e3391e8ed3cde93346c6200a72c4df02a68ce991db5ee4da0d18

That has the ‘0x’ in front… so do I?

cdv hash 0xcdd99ce61659e3391e8ed3cde93346c6200a72c4df02a68ce991db5ee4da0d18

Output:
b71da5dee38d98000378948afed4b2c7f313f08d05c384752c918e4fad0ca876

cdv encode b71da5dee38d98000378948afed4b2c7f313f08d05c384752c918e4fad0ca876
Output:
xch1kuw6thhr3kvqqqmcjj90a49jcle38uydqhpcgafvjx8yltgv4pmq8faqqp

Ok… Success… I think I need to learn some more about addresses.

So for everyone wondering how… may just be me. Here are the details.

Get the original transactions by:
chia wallet get_transactions -v
or
chia wallet get_transactions
get the Transaction# and run the command below
chia wallet get_transaction -tx TransactionID

   my example yields: 
       0x9cafe6ce83ea11a5fd35a4cfbf658c0863c2b9d042b97b0a5049cfd2ce0d5888

then get the “parent_coin_info” like Rigidity said and place it in the below statement
cdv rpc coinrecords --by id 0x…

then get the “puzzle_hash” from the output:

  my example yields
  0xcdd99ce61659e3391e8ed3cde93346c6200a72c4df02a68ce991db5ee4da0d18

Remove the 0x and run this code on it:
cdv encode cdd…d18

Sending to this address returns the chia to the wallet that sent it

 my example yields:
 xch1ehveeeskt83nj85w60x7jv6xccsq5ukymup2dr8fj8d4aex6p5vq4e7ggn

Thanks Rigidity for your help and pointing me in the right direction!