mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge bitcoin/bitcoin#24845: wallet: return error msg for "too-long-mempool-chain"
f3221d373atest: add wallet too-long-mempool-chain error coverage (furszy)acf0119d24wallet: return error msg for too-long-mempool-chain failure (furszy) Pull request description: Fixes #23144. We currently return a general "Insufficient funds" from Coin Selection when we actually skipped unconfirmed UTXOs that surpassed the mempool ancestors limit. This PR make the error clearer by returning: "Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool" Also, added an early return from Coin Selection if the sum of the discarded coins decreases the available balance below the target amount. ACKs for top commit: achow101: ACKf3221d373aS3RK: Code review ACKf3221d373aXekyo: ACKf3221d373aTree-SHA512: 13e5824b75ac302280ff894560a4ebf32a74f32fe49ef8281f2bc99c0104b92cef33d3b143c6e131f3a07eafe64533af7fc60abff585142c134b9d6e531a6a66
This commit is contained in:
@@ -32,6 +32,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
||||
|
||||
self.test_anti_fee_sniping()
|
||||
self.test_tx_size_too_large()
|
||||
self.test_create_too_long_mempool_chain()
|
||||
|
||||
def test_anti_fee_sniping(self):
|
||||
self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled')
|
||||
@@ -80,6 +81,30 @@ class CreateTxWalletTest(BitcoinTestFramework):
|
||||
)
|
||||
self.nodes[0].settxfee(0)
|
||||
|
||||
def test_create_too_long_mempool_chain(self):
|
||||
self.log.info('Check too-long mempool chain error')
|
||||
df_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
|
||||
|
||||
self.nodes[0].createwallet("too_long")
|
||||
test_wallet = self.nodes[0].get_wallet_rpc("too_long")
|
||||
|
||||
tx_data = df_wallet.send(outputs=[{test_wallet.getnewaddress(): 25}], options={"change_position": 0})
|
||||
txid = tx_data['txid']
|
||||
vout = 1
|
||||
|
||||
options = {"change_position": 0, "add_inputs": False}
|
||||
for i in range(1, 25):
|
||||
options['inputs'] = [{'txid': txid, 'vout': vout}]
|
||||
tx_data = test_wallet.send(outputs=[{test_wallet.getnewaddress(): 25 - i}], options=options)
|
||||
txid = tx_data['txid']
|
||||
|
||||
# Sending one more chained transaction will fail
|
||||
options = {"minconf": 0, "include_unsafe": True, 'add_inputs': True}
|
||||
assert_raises_rpc_error(-4, "Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool",
|
||||
test_wallet.send, outputs=[{test_wallet.getnewaddress(): 0.3}], options=options)
|
||||
|
||||
test_wallet.unloadwallet()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
CreateTxWalletTest().main()
|
||||
|
||||
Reference in New Issue
Block a user