mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
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
This commit is contained in:
parent
361d254524
commit
719d9a542c
@ -774,6 +774,8 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid)
|
|||||||
mapTxSpends.insert(std::make_pair(outpoint, wtxid));
|
mapTxSpends.insert(std::make_pair(outpoint, wtxid));
|
||||||
setWalletUTXO.erase(outpoint);
|
setWalletUTXO.erase(outpoint);
|
||||||
|
|
||||||
|
setLockedCoins.erase(outpoint);
|
||||||
|
|
||||||
std::pair<TxSpends::iterator, TxSpends::iterator> range;
|
std::pair<TxSpends::iterator, TxSpends::iterator> range;
|
||||||
range = mapTxSpends.equal_range(outpoint);
|
range = mapTxSpends.equal_range(outpoint);
|
||||||
SyncMetaData(range);
|
SyncMetaData(range);
|
||||||
|
@ -114,6 +114,15 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
self.nodes[2].lockunspent, False,
|
self.nodes[2].lockunspent, False,
|
||||||
[{"txid": unspent_0["txid"], "vout": 999}])
|
[{"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)
|
# Have node1 generate 100 blocks (so node0 can recover the fee)
|
||||||
self.nodes[1].generate(100)
|
self.nodes[1].generate(100)
|
||||||
self.sync_all(self.nodes[0:3])
|
self.sync_all(self.nodes[0:3])
|
||||||
|
Loading…
Reference in New Issue
Block a user