Skip to content

Commit 868cf43

Browse files
committed
Merge #13160: wallet: Unlock spent outputs
fd9b3a7 test: Output should be unlocked when spent (João Barbosa) 54c3bb4 wallet: Unlock spent outputs (João Barbosa) Pull request description: Fixes #12738. Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
2 parents 08516e0 + fd9b3a7 commit 868cf43

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
609609
{
610610
mapTxSpends.insert(std::make_pair(outpoint, wtxid));
611611

612+
setLockedCoins.erase(outpoint);
613+
612614
std::pair<TxSpends::iterator, TxSpends::iterator> range;
613615
range = mapTxSpends.equal_range(outpoint);
614616
SyncMetaData(range);

test/functional/wallet_basic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ def run_test(self):
129129
self.nodes[2].lockunspent, False,
130130
[{"txid": unspent_0["txid"], "vout": 999}])
131131

132+
# An output should be unlocked when spent
133+
unspent_0 = self.nodes[1].listunspent()[0]
134+
self.nodes[1].lockunspent(False, [unspent_0])
135+
tx = self.nodes[1].createrawtransaction([unspent_0], { self.nodes[1].getnewaddress() : 1 })
136+
tx = self.nodes[1].fundrawtransaction(tx)['hex']
137+
tx = self.nodes[1].signrawtransactionwithwallet(tx)["hex"]
138+
self.nodes[1].sendrawtransaction(tx)
139+
assert_equal(len(self.nodes[1].listlockunspent()), 0)
140+
132141
# Have node1 generate 100 blocks (so node0 can recover the fee)
133142
self.nodes[1].generate(100)
134143
self.sync_all([self.nodes[0:3]])

0 commit comments

Comments
 (0)