External signers such as Ledger, BitBox02 and Jade, when used with multisig, use BIP388 to display (and constrain) descriptor policies to their users.
At least in the case of Ledger (haven’t tested the others) this requires us to hold on to an hmac, which proves to the device that the user previously reviewed and approved it.
This PR adds a new RPC call registerpolicy
which converts our descriptor(s) into a BIP388 policy (partially implemented), calls a new HWI method register
(implemented) and stores the resulting HMAC (implemented).
When signing a transaction using HWI’s signtx
it passes the HMAC along with the PSBT (TODO).
For convenience the HMAC can be retrieved via getwalletinfo
(implemented). This is useful for scenario’s where we can’t (yet) complete a transaction via HWI calls.
Note that the HMAC itself is not specified in BIP388 and may be different for different hardware vendors. So we’ll store and echo any hex string the device gives us.
An alternative approach to directly supporting BIP388 policies would be to pass the involved descriptors to HWI and have it figure out how to derive a policy.
Testing:
- make a multisig wallet with a Ledger or other supported device
- try https://github.com/Sjors/bitcoin/pull/91 if you’re feeling adventurous, it includes this PR
- install https://github.com/bitcoin-core/HWI/pull/791 HWI branch
- call
bitcoin rpc registerpolicy
- call
bitcoin rpc getwalletinfo
to see the hmac
TODO:
- derive policy using
Descriptor
class instead regex madness, implement all constraints - pass hmac along when signing
Depends on:
- HWI
register
command: https://github.com/bitcoin-core/HWI/pull/791 - HWI optional
--hmac
argument forsigntx
(if set, bypass the current auto-registration workaround)
Potential followups:
- pass hmac along when displaying an address. This provides some extra assurance to the user. See https://github.com/bitcoin-core/HWI/pull/647