mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge #18546: Bugfix: Wallet: Safely deal with change in the address book [part 2]
7a2ecf16dfWallet: Change IsMine check in CWallet::DelAddressBook from assert to failure (Luke Dashjr)2952c46b92Wallet: Replace CAddressBookData.name with GetLabel() method (Luke Dashjr)d7092c392eQA: Test that change doesn't turn into non-change when spent in an avoid-reuse wallet (Luke Dashjr) Pull request description: Follow-up to #18192, not strictly necessary for 0.20 ACKs for top commit: MarcoFalke: re-ACK7a2ecf16df, only change is adding an assert_equal in the test 🔰 jnewbery: utACK7a2ecf16dfTree-SHA512: e0933ee40f705b751697dc27249e1868ed4874254b174ebdd0a7150125d8c818402e66df2371718c7eeb90e67ee2317215fb260aa9b9d7b9b45ee436de2988ff
This commit is contained in:
@@ -83,6 +83,7 @@ class AvoidReuseTest(BitcoinTestFramework):
|
||||
|
||||
self.nodes[0].generate(110)
|
||||
self.sync_all()
|
||||
self.test_change_remains_change(self.nodes[1])
|
||||
reset_balance(self.nodes[1], self.nodes[0].getnewaddress())
|
||||
self.test_fund_send_fund_senddirty()
|
||||
reset_balance(self.nodes[1], self.nodes[0].getnewaddress())
|
||||
@@ -137,6 +138,30 @@ class AvoidReuseTest(BitcoinTestFramework):
|
||||
# Unload temp wallet
|
||||
self.nodes[1].unloadwallet(tempwallet)
|
||||
|
||||
def test_change_remains_change(self, node):
|
||||
self.log.info("Test that change doesn't turn into non-change when spent")
|
||||
|
||||
reset_balance(node, node.getnewaddress())
|
||||
addr = node.getnewaddress()
|
||||
txid = node.sendtoaddress(addr, 1)
|
||||
out = node.listunspent(minconf=0, query_options={'minimumAmount': 2})
|
||||
assert_equal(len(out), 1)
|
||||
assert_equal(out[0]['txid'], txid)
|
||||
changeaddr = out[0]['address']
|
||||
|
||||
# Make sure it's starting out as change as expected
|
||||
assert node.getaddressinfo(changeaddr)['ischange']
|
||||
for logical_tx in node.listtransactions():
|
||||
assert logical_tx.get('address') != changeaddr
|
||||
|
||||
# Spend it
|
||||
reset_balance(node, node.getnewaddress())
|
||||
|
||||
# It should still be change
|
||||
assert node.getaddressinfo(changeaddr)['ischange']
|
||||
for logical_tx in node.listtransactions():
|
||||
assert logical_tx.get('address') != changeaddr
|
||||
|
||||
def test_fund_send_fund_senddirty(self):
|
||||
'''
|
||||
Test the same as test_fund_send_fund_send, except send the 10 BTC with
|
||||
|
||||
Reference in New Issue
Block a user