Skip to content

Commit

Permalink
test: use getxpub in wallet_multisig_descriptor_psbt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Nov 6, 2023
1 parent e7796cd commit 3afb2f9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions test/functional/wallet_multisig_descriptor_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
self.skip_if_no_sqlite()

@staticmethod
def _get_xpub(wallet):
"""Extract the wallet's xpubs using `listdescriptors` and pick the one from the `pkh` descriptor since it's least likely to be accidentally reused (legacy addresses)."""
descriptor = next(filter(lambda d: d["desc"].startswith("pkh"), wallet.listdescriptors()["descriptors"]))
return descriptor["desc"].split("]")[-1].split("/")[0]

@staticmethod
def _check_psbt(psbt, to, value, multisig):
"""Helper function for any of the N participants to check the psbt with decodepsbt and verify it is OK before signing."""
Expand Down Expand Up @@ -93,7 +87,9 @@ def run_test(self):
}

self.log.info("Generate and exchange xpubs...")
xpubs = [self._get_xpub(signer) for signer in participants["signers"]]
# Reuse `pkh` descriptor keys, since it's least likely to be accidentally reused (legacy addresses)
# TODO: use BIP87's recommended m/87'/1'/0' once importdescriptors can infer private keys for arbitrary derivations
xpubs = [signer.getxpub("m/44'/1'/0'")["xpub"] for signer in participants["signers"]]

self.log.info("Every participant imports the following descriptors to create the watch-only multisig...")
participants["multisigs"] = list(self.participants_create_multisigs(xpubs))
Expand Down

0 comments on commit 3afb2f9

Please sign in to comment.