From e05cd0546a155afcd45c43ce730c4abecd40dfed Mon Sep 17 00:00:00 2001 From: Michael Dietz Date: Wed, 26 May 2021 10:38:12 -0400 Subject: [PATCH] doc: add another signing flow for multisig with descriptor wallets and PSBTs --- doc/descriptors.md | 5 +++++ .../wallet_multisig_descriptor_psbt.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/descriptors.md b/doc/descriptors.md index ab04f64b6b..75b9582343 100644 --- a/doc/descriptors.md +++ b/doc/descriptors.md @@ -162,6 +162,11 @@ The basic steps are: then the resulting transaction is broadcasted to the network 8. Checks that balances are correct after the transaction has been included in a block +You may prefer a daisy chained signing flow where each participant signs the PSBT one after another until +the PSBT has been signed `M` times and is "complete." For the most part, the steps above remain the same, except (6, 7) +change slightly from signing the original PSBT in parallel to signing it in series. `combinepsbt` is not necessary with +this signing flow and the last (`m`th) signer can just broadcast the PSBT after signing. Note that a parallel signing flow may be +preferable in cases where there are more signers. This signing flow is also included in the test / Python example. [The test](/test/functional/wallet_multisig_descriptor_psbt.py) is meant to be documentation as much as it is a functional test, so it is kept as simple and readable as possible. diff --git a/test/functional/wallet_multisig_descriptor_psbt.py b/test/functional/wallet_multisig_descriptor_psbt.py index e8b9ad8f2a..59a0b94a9f 100755 --- a/test/functional/wallet_multisig_descriptor_psbt.py +++ b/test/functional/wallet_multisig_descriptor_psbt.py @@ -139,5 +139,21 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework): assert_approx(self.nodes[0].get_wallet_rpc(f"{self.name}_{0}").getbalance(), deposit_amount - value, vspan=0.001) assert_equal(self.nodes[self.N - 1].get_wallet_rpc(f"participant_{self.N - 1}").getbalance(), value) + self.log.info("Send another transaction from the multisig, this time with a daisy chained signing flow (one after another in series)!") + psbt = self.make_sending_transaction(to, value) + for m in range(self.M): + signing_wallet = self.nodes[m].get_wallet_rpc(f"participant_{m}") + psbt = signing_wallet.walletprocesspsbt(psbt["psbt"]) + assert_equal(psbt["complete"], m == self.M - 1) + finalized = coordinator_wallet.finalizepsbt(psbt["psbt"]) + coordinator_wallet.sendrawtransaction(finalized["hex"]) + + self.log.info("Check that balances are correct after the transaction has been included in a block.") + self.nodes[0].generate(1) + self.sync_all() + assert_approx(self.nodes[0].get_wallet_rpc(f"{self.name}_{0}").getbalance(), deposit_amount - (value * 2), vspan=0.001) + assert_equal(self.nodes[self.N - 1].get_wallet_rpc(f"participant_{self.N - 1}").getbalance(), value * 2) + + if __name__ == "__main__": WalletMultisigDescriptorPSBTTest().main()