mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge bitcoin/bitcoin#23202: wallet: allow psbtbumpfee to work with txs with external inputs
c3b099ace0wallet, tests: Test bumpfee's max input weight calculation (Andrew Chow)116a620ce7Make DUMMY_CHECKER availble outside of script/sign.cpp (Andrew Chow)ff638323d1test, bumpfee: Check that psbtbumpfee can bump txs with external inputs (Andrew Chow)1bc8106d4cbumpfee: be able to bump fee of a tx with external inputs (Andrew Chow)31dd3dc9e5bumpfee: Clear scriptSigs and scriptWitnesses before calculated max size (Andrew Chow)a0c3afb898bumpfee: extract weights of external inputs when bumping fee (Andrew Chow)612f1e44febumpfee: Calculate fee by looking up UTXOs (Andrew Chow) Pull request description: This PR allows `psbtbumpfee` to return a PSBT for transactions that contain external inputs. This does not work for bumping in the GUI nor `bumpfee` because these need private keys available to sign and send the transaction. But `psbtbumpfee` returns a psbt, so it is fine to not be able to sign. In order to correctly estimate the size of the inputs for coin selection, the fee bumper will use the size of the inputs of the transaction being bumped. Because the sizes of signatures are not guaranteed, for external inputs, the fee bumper will verify the scripts with a special SignatureChecker which will compute the weight of all of the signatures in that input, and compute their weights if those signatures were maximally sized. This allows the fee bumper to obtain a max size estimate for each external input. Builds on #23201 as it relies on the ability to pass weights in to coin selection. Closes #23189 ACKs for top commit: ishaanam: reACKc3b099ace0t-bast: Re-ran my tests againsc3b099ace0, ACK Tree-SHA512: 40016ec52d351430977579cfa2694c7e6764f42c9ce09d3a6f1753b767f86053f296d9de988248df033be6d725d67badbf2a5ef82c8ace23c61487729b7691e5
This commit is contained in:
@@ -86,7 +86,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
||||
self.test_invalid_parameters(rbf_node, peer_node, dest_address)
|
||||
test_segwit_bumpfee_succeeds(self, rbf_node, dest_address)
|
||||
test_nonrbf_bumpfee_fails(self, peer_node, dest_address)
|
||||
test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address)
|
||||
test_notmine_bumpfee(self, rbf_node, peer_node, dest_address)
|
||||
test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_address)
|
||||
test_dust_to_fee(self, rbf_node, dest_address)
|
||||
test_watchonly_psbt(self, peer_node, rbf_node, dest_address)
|
||||
@@ -232,7 +232,7 @@ def test_nonrbf_bumpfee_fails(self, peer_node, dest_address):
|
||||
self.clear_mempool()
|
||||
|
||||
|
||||
def test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address):
|
||||
def test_notmine_bumpfee(self, rbf_node, peer_node, dest_address):
|
||||
self.log.info('Test that it cannot bump fee if non-owned inputs are included')
|
||||
# here, the rbftx has a peer_node coin and then adds a rbf_node input
|
||||
# Note that this test depends upon the RPC code checking input ownership prior to change outputs
|
||||
@@ -250,8 +250,27 @@ def test_notmine_bumpfee_fails(self, rbf_node, peer_node, dest_address):
|
||||
signedtx = rbf_node.signrawtransactionwithwallet(rawtx)
|
||||
signedtx = peer_node.signrawtransactionwithwallet(signedtx["hex"])
|
||||
rbfid = rbf_node.sendrawtransaction(signedtx["hex"])
|
||||
entry = rbf_node.getmempoolentry(rbfid)
|
||||
old_fee = entry["fees"]["base"]
|
||||
old_feerate = int(old_fee / entry["vsize"] * Decimal(1e8))
|
||||
assert_raises_rpc_error(-4, "Transaction contains inputs that don't belong to this wallet",
|
||||
rbf_node.bumpfee, rbfid)
|
||||
|
||||
def finish_psbtbumpfee(psbt):
|
||||
psbt = rbf_node.walletprocesspsbt(psbt)
|
||||
psbt = peer_node.walletprocesspsbt(psbt["psbt"])
|
||||
final = rbf_node.finalizepsbt(psbt["psbt"])
|
||||
res = rbf_node.testmempoolaccept([final["hex"]])
|
||||
assert res[0]["allowed"]
|
||||
assert_greater_than(res[0]["fees"]["base"], old_fee)
|
||||
|
||||
self.log.info("Test that psbtbumpfee works for non-owned inputs")
|
||||
psbt = rbf_node.psbtbumpfee(txid=rbfid)
|
||||
finish_psbtbumpfee(psbt["psbt"])
|
||||
|
||||
psbt = rbf_node.psbtbumpfee(txid=rbfid, options={"fee_rate": old_feerate + 10})
|
||||
finish_psbtbumpfee(psbt["psbt"])
|
||||
|
||||
self.clear_mempool()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user