rpc: add "ischange: true" in wallet gettransaction decoded tx output

This commit is contained in:
Matthew Zipkin
2025-05-15 11:32:04 -04:00
parent c779ee3a40
commit d633db5416
5 changed files with 25 additions and 6 deletions

View File

@@ -542,13 +542,16 @@ class WalletTest(BitcoinTestFramework):
destination = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(destination, 0.123)
tx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded']
output_addresses = [vout['scriptPubKey']['address'] for vout in tx["vout"]]
assert len(output_addresses) > 1
for address in output_addresses:
assert len(tx["vout"]) > 1
for vout in tx["vout"]:
address = vout['scriptPubKey']['address']
ischange = self.nodes[0].getaddressinfo(address)['ischange']
assert_equal(ischange, address != destination)
if ischange:
change = address
assert vout["ischange"]
else:
assert "ischange" not in vout
self.nodes[0].setlabel(change, 'foobar')
assert_equal(self.nodes[0].getaddressinfo(change)['ischange'], False)