diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-06-24 18:52:27 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-06-24 18:52:30 +0200 |
commit | 868cf431be1fc3f349d85b90772954f7919f5910 (patch) | |
tree | eb4320fc479dc3268db1bac5a90ea141a1a256ce | |
parent | 08516e0e65d589dc754b2d50527304cdc0132cb2 (diff) | |
parent | fd9b3a71824e33728f267e6f288b6224ad1047e1 (diff) |
Merge #13160: wallet: Unlock spent outputs
fd9b3a71824e33728f267e6f288b6224ad1047e1 test: Output should be unlocked when spent (João Barbosa)
54c3bb4cf805ccee91efb9f8cdadea87e0797989 wallet: Unlock spent outputs (João Barbosa)
Pull request description:
Fixes #12738.
Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
-rw-r--r-- | src/wallet/wallet.cpp | 2 | ||||
-rwxr-xr-x | test/functional/wallet_basic.py | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6255f28b17..842516bb0e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -609,6 +609,8 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid) { mapTxSpends.insert(std::make_pair(outpoint, wtxid)); + setLockedCoins.erase(outpoint); + std::pair<TxSpends::iterator, TxSpends::iterator> range; range = mapTxSpends.equal_range(outpoint); SyncMetaData(range); diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 9c58b84819..d6a64eaefb 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -129,6 +129,15 @@ class WalletTest(BitcoinTestFramework): self.nodes[2].lockunspent, False, [{"txid": unspent_0["txid"], "vout": 999}]) + # An output should be unlocked when spent + unspent_0 = self.nodes[1].listunspent()[0] + self.nodes[1].lockunspent(False, [unspent_0]) + tx = self.nodes[1].createrawtransaction([unspent_0], { self.nodes[1].getnewaddress() : 1 }) + tx = self.nodes[1].fundrawtransaction(tx)['hex'] + tx = self.nodes[1].signrawtransactionwithwallet(tx)["hex"] + self.nodes[1].sendrawtransaction(tx) + assert_equal(len(self.nodes[1].listlockunspent()), 0) + # Have node1 generate 100 blocks (so node0 can recover the fee) self.nodes[1].generate(100) self.sync_all([self.nodes[0:3]]) |