Skip to content

Optionally pass BIP388 policy to signtx - #792

Draft
Sjors wants to merge 22 commits into
bitcoin-core:masterfrom
Sjors:2025/07/policy-sign
Draft

Optionally pass BIP388 policy to signtx#792
Sjors wants to merge 22 commits into
bitcoin-core:masterfrom
Sjors:2025/07/policy-sign

Conversation

@Sjors

@Sjors Sjors commented Jul 21, 2025

Copy link
Copy Markdown
Member

Another step toward #785. This builds on #842.

This adds optional registered BIP388 descriptor policy information to
signtx. Existing signtx usage remains unchanged when no registration
is supplied.

signtx accepts --registration, containing the serialized
RegisteredDescriptor returned by the registerdescriptor command from
#842. The registration contains the policy name, descriptor, device type,
and any device-specific registration data, so separate --policy-desc
and --policy-name arguments are not needed.

Example:

hwi --device-type ledger signtx \
  --registration "cmRlc2M..." \
  "cHNidP..."

This was referenced Jul 21, 2025
@Sjors
Sjors force-pushed the 2025/07/policy-sign branch 7 times, most recently from 31a9714 to dfd11e0 Compare July 30, 2025 19:02
@Sjors

Sjors commented Jul 31, 2025

Copy link
Copy Markdown
Member Author

Coldcard CI failure is probably spurious.

@Sjors

Sjors commented Sep 4, 2025

Copy link
Copy Markdown
Member Author

Rebased after #795 landed.

@Sjors

Sjors commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

I'll update this after #836, taking the latest changes in #794 into account.

@Sjors
Sjors marked this pull request as draft July 4, 2026 09:40
@Sjors
Sjors force-pushed the 2025/07/policy-sign branch from b53160a to 5efe2fd Compare July 31, 2026 08:00
@Sjors
Sjors marked this pull request as ready for review July 31, 2026 08:00
@Sjors

Sjors commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Rebased after #836.

@Sjors
Sjors marked this pull request as draft August 1, 2026 18:51
@Sjors
Sjors force-pushed the 2025/07/policy-sign branch from 5efe2fd to 2b7270b Compare August 2, 2026 10:15
@Sjors

Sjors commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

This now uses the same approach as #791, with the first two commits shared, so I'll keep this draft.

The sort in sortedmulti occurs only during script expansion. Keep the
pubkeys in the order that they were provided to the parser.
For BIP388 policies, we will need to know wht index of each key
expression, so keep track of them explicitly with a key expression index
stored in each PubkeyProvider.

This also mirrors what Bitcoin Core does for descriptors.
The derivation path should be parsed and validated for correctness, not
just copied directly into a pubkey provider.
get_bip388_template returns the descriptor as a BIP 388 Wallet
Descriptor Template string.

get_pubkey_providers returns all of the pubkey providers from the
descriptor, in the same order as the placeholders in the bip388
template. Callers can get the strings for the key information vector by
calling PubkeyProvider.to_string_no_deriv()
After a descriptor is registered, we want to return to the caller some
information about the registration. RegisteredDescriptor is a class that
contains the name, the descriptor, the device type, and any data that
the device returned in response to the registration. This class can be
de/serialized from/to a string.
achow101 and others added 11 commits August 5, 2026 15:28
Adds registerdescriptor CLI command and its handlers.

Adds register_descriptor to HardwareWalletClient with boilerplate
implementation.
BitBox01, Trezor, and Keepkey do not support registering descriptors.
Implement the function as a throw.
Co-authored-by: Codex (GPT-5.6 Sol) <noreply@openai.com>
Accept a serialized registered descriptor with signtx and dispatch policy signing through a dedicated device method.
Extend the generic descriptor registration test to fund, sign, and finalize a transaction spending from the registered policy.
Reconstruct the registered wallet policy and pass its registration HMAC when signing the PSBT.
@Sjors
Sjors force-pushed the 2025/07/policy-sign branch from 6d541f6 to b562044 Compare August 6, 2026 08:40
@Sjors

Sjors commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Rebased and now using RegisteredDescriptor from #842. I still need to polish the commits. This also has some overlap with #841 so I suggest reviewing that first.

Sjors added 5 commits August 6, 2026 14:10
HWI's Coldcard simulator patch stores multiple derivation paths per
fingerprint so one seed can represent several multisig cosigners.

get_xfp_paths() iterates fingerprint keys instead of path lists. This
breaks descriptor enrollment and later signing fails with "Unknown
multisig wallet". Iterate over the mapping values instead.
Sign with the existing PSBT flow after registerdescriptor has stored the policy on the device.
Sign with the existing PSBT flow after registerdescriptor has stored the policy on the device.
Move descriptor-to-policy translation into a reusable helper without changing registration behavior.
Translate the registered descriptor into the policy script configuration and use it for transaction inputs and change outputs.
@Sjors
Sjors force-pushed the 2025/07/policy-sign branch from b562044 to 43c0b51 Compare August 6, 2026 12:13
@Sjors

Sjors commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

ColdCard's multisig simulator patch, needed a patch 12ccec2. This belongs in #842 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants