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 (TODO), 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). Ditto for displayaddress
(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.
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
- modify
devices/ledger.py
in HWI to printregistered_hmac.hex()
(to verify correctness later) - install https://github.com/bitcoin-core/HWI/pull/791 HWI branch
- edit
src/wallet/external_signer_scriptppubkeyman.cpp
and change the hardcodeddescriptor_template
andkeys_info
to your own wallet (this step will go away, see TODO below) - call
bitcoin rpc registerpolicy
- check that the result contains the hmac from before
TODO:
- derive BIP388 descriptor template from descriptor
- 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