mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-01 09:35:52 -05:00
test: exercise bip32_deriv stripping during psbt combine
These asserts check that when calling `combinepsbt` RPC with `stripderivs=true`, all derivation paths are stripped from all inputs and outputs.
This commit is contained in:
parent
e5aa7d96b4
commit
6f5b910876
1 changed files with 25 additions and 0 deletions
|
@ -128,10 +128,35 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework):
|
||||||
psbts.append(partially_signed_psbt["psbt"])
|
psbts.append(partially_signed_psbt["psbt"])
|
||||||
|
|
||||||
self.log.info("Finally, collect the signed PSBTs with combinepsbt, finalizepsbt, then broadcast the resulting transaction...")
|
self.log.info("Finally, collect the signed PSBTs with combinepsbt, finalizepsbt, then broadcast the resulting transaction...")
|
||||||
|
|
||||||
combined = coordinator_wallet.combinepsbt(psbts)
|
combined = coordinator_wallet.combinepsbt(psbts)
|
||||||
|
combined_stripped = coordinator_wallet.combinepsbt(psbts, stripderivs=True)
|
||||||
|
|
||||||
|
combined_decoded = coordinator_wallet.decodepsbt(combined)
|
||||||
|
combined_decoded_stripped = coordinator_wallet.decodepsbt(combined_stripped)
|
||||||
|
|
||||||
|
self.log.info("Check that we can strip bip32 derivation information from all inputs and outputs using combinepsbt")
|
||||||
|
for key in ['inputs', 'outputs']:
|
||||||
|
# Test for presence
|
||||||
|
for item in combined_decoded[key]:
|
||||||
|
# Only check these those that are not empty
|
||||||
|
if item:
|
||||||
|
assert "bip32_derivs" in item, f"{key} must contain 'bip32_derivs'"
|
||||||
|
# Test for absence
|
||||||
|
for item in combined_decoded_stripped[key]:
|
||||||
|
if item:
|
||||||
|
assert "bip32_derivs" not in item, f"'bip32_derivs' should not be in {key}"
|
||||||
|
|
||||||
finalized = coordinator_wallet.finalizepsbt(combined)
|
finalized = coordinator_wallet.finalizepsbt(combined)
|
||||||
coordinator_wallet.sendrawtransaction(finalized["hex"])
|
coordinator_wallet.sendrawtransaction(finalized["hex"])
|
||||||
|
|
||||||
|
self.log.info("Check that we can strip bip32 derivation information from a single psbt using combinepsbt")
|
||||||
|
psbts2 = [psbts[0],]
|
||||||
|
combined_single_stripped = coordinator_wallet.combinepsbt(psbts2, stripderivs=True)
|
||||||
|
combined_single_stripped_decoded = coordinator_wallet.decodepsbt(combined_single_stripped)
|
||||||
|
assert "bip32_derivs" not in combined_single_stripped_decoded["inputs"][0]
|
||||||
|
assert "bip32_derivs" not in combined_single_stripped_decoded["outputs"][0]
|
||||||
|
|
||||||
self.log.info("Check that balances are correct after the transaction has been included in a block.")
|
self.log.info("Check that balances are correct after the transaction has been included in a block.")
|
||||||
self.generate(self.nodes[0], 1)
|
self.generate(self.nodes[0], 1)
|
||||||
assert_approx(participants["multisigs"][0].getbalance(), deposit_amount - value, vspan=0.001)
|
assert_approx(participants["multisigs"][0].getbalance(), deposit_amount - value, vspan=0.001)
|
||||||
|
|
Loading…
Add table
Reference in a new issue