Wallet/RPC: Allow specifying min & max chain depth for inputs used by fund calls

Enables users to craft BIP-125 replacements with changes to the output
list, ensuring that if additional funds are needed they will be added.
This commit is contained in:
Juan Pablo Civile
2021-05-24 10:22:10 -03:00
committed by ishaanam
parent 329d7e379d
commit a07a413466
5 changed files with 170 additions and 1 deletions

View File

@ -45,7 +45,7 @@ class WalletSendTest(BitcoinTestFramework):
conf_target=None, estimate_mode=None, fee_rate=None, add_to_wallet=None, psbt=None,
inputs=None, add_inputs=None, include_unsafe=None, change_address=None, change_position=None, change_type=None,
include_watching=None, locktime=None, lock_unspents=None, replaceable=None, subtract_fee_from_outputs=None,
expect_error=None, solving_data=None):
expect_error=None, solving_data=None, minconf=None):
assert (amount is None) != (data is None)
from_balance_before = from_wallet.getbalances()["mine"]["trusted"]
@ -106,6 +106,8 @@ class WalletSendTest(BitcoinTestFramework):
options["subtract_fee_from_outputs"] = subtract_fee_from_outputs
if solving_data is not None:
options["solving_data"] = solving_data
if minconf is not None:
options["minconf"] = minconf
if len(options.keys()) == 0:
options = None
@ -487,6 +489,16 @@ class WalletSendTest(BitcoinTestFramework):
res = self.test_send(from_wallet=w5, to_wallet=w0, amount=1, include_unsafe=True)
assert res["complete"]
self.log.info("Minconf")
self.nodes[1].createwallet(wallet_name="minconfw")
minconfw= self.nodes[1].get_wallet_rpc("minconfw")
self.test_send(from_wallet=w0, to_wallet=minconfw, amount=2)
self.generate(self.nodes[0], 3)
self.test_send(from_wallet=minconfw, to_wallet=w0, amount=1, minconf=4, expect_error=(-4, "Insufficient funds"))
self.test_send(from_wallet=minconfw, to_wallet=w0, amount=1, minconf=-4, expect_error=(-8, "Negative minconf"))
res = self.test_send(from_wallet=minconfw, to_wallet=w0, amount=1, minconf=3)
assert res["complete"]
self.log.info("External outputs")
eckey = ECKey()
eckey.generate()