-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic taproot BIP32 derivation & keyspend support #33
Basic taproot BIP32 derivation & keyspend support #33
Conversation
FYI - still making improvements and tweaks so this PR should be considered DRAFT (but I don't seem to have permissions to revert the PR status to DRAFT). |
Converted to draft |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSBT parsing should not fail if the library can't sign - maybe it's not used for signing at all. You can raise when signing, but I'd better ignore inputs we don't know how to sign.
For example, when you try to sign PSBT transaction with a wrong key it doesn't raise an error, it just returns 0 as a number of added signatures. I think for tap leafs we should do the same.
Extracts the pubkey and derivation path from BIP-371 `PSBT_IN_TAP_BIP32_DERIVATION` field, but only when there are no leaf hashes.
*Adds "legacy" support for Taproot psbts that don't have BIP-371 `PSBT_IN_TAP_BIP32_DERIVATION` field.
6346888
to
ab0cdd6
Compare
PSBT_IN_TAP_BIP32_DERIVATION
(0x16
) to properly parse bip32 derivations in Taproot psbts.PSBT_IN_TAP_INTERNAL_KEY
(0x17
), though I believe it won't be needed until keys within leaves are supported (internal key will match thePSBT_IN_TAP_BIP32_DERIVATION
pubkey whennum_leaf_hashes
is zero).PSBT_OUT_TAP_INTERNAL_KEY
(0x05
) andPSBT_OUT_TAP_BIP32_DERIVATION
(0x07
) fields to outputs.InputScope.taproot_bip32_derivations
which is a tuple:([leaf_hashes], DerivationPath)
. Same forOutputScope.taproot_bip32_derivations
.InputScope.taproot_internal_key
andOutputScope.taproot_internal_key
.PSBT_IN_TAP_BIP32_DERIVATION
field (i.e. they populate0x06
/InputScope.bip32_derivations
).taproot_bip32_derivations
were populated and adds fixes so that the X-only pubkeys expectation passes.I will also try to make a PR to update Specter Desktop to output the
0x16
and0x17
BIP-371 fields. Because of the backwards-compatibility here, a Specter-DIY release can come first and then update Specter Desktop with these fields.TODO:
Update
test_tapoot.TaprootTest.test_sign_verify
to use a psbt that includes thePSBT_IN_TAP_BIP32_DERIVATION
field rather than the "legacy" psbt approach.TODO:
test_psbtview.PSBTViewTest
is failing ontest_sign
:This failure pre-dates these changes so something was either already broken or something is off with my local setup.