multi: introduce and use new TapTweak and SignMethod fields
In this commit, we add a new field `TapTweak` to be used for key path spends. Before this commit, we'd overload the existing `WitnessScript` field to pass this information to the signing context. This was confusing as for tapscript spends, this was the leaf script, which mirrors the other script based spending types. With this new filed, users need to set this to the script root for keypath spends where the output key commits to a real merkle root, and nothing when bip 86 spending is being used. To make the signing even more explicit, we also add a new field called sign_method with an enum type that differentiates between the different segwit v0 and v1 signing methods. Fixes https://github.com/lightningnetwork/lnd/issues/6446.
This commit is contained in:
1 parent
99cda74f6a
commit
630fc36dcf
7 files changed
+610
-358
No files matched your search
@@ -175,6 +175,32 @@ message TxOut {
|
||||
bytes pk_script = 2;
|
||||
}
|
||||
|
||||
enum SignMethod {
|
||||
/*
|
||||
Specifies that a SegWit v0 (p2wkh, np2wkh, p2wsh) input script should be
|
||||
signed.
|
||||
*/
|
||||
SIGN_METHOD_WITNESS_V0 = 0;
|
||||
|
||||
/*
|
||||
Specifies that a SegWit v1 (p2tr) input should be signed by using the
|
||||
BIP0086 method (commit to internal key only).
|
||||
*/
|
||||
SIGN_METHOD_TAPROOT_KEY_SPEND_BIP0086 = 1;
|
||||
|
||||
/*
|
||||
Specifies that a SegWit v1 (p2tr) input should be signed by using a given
|
||||
taproot hash to commit to in addition to the internal key.
|
||||
*/
|
||||
SIGN_METHOD_TAPROOT_KEY_SPEND = 2;
|
||||
|
||||
/*
|
||||
Specifies that a SegWit v1 (p2tr) input should be spent using the script
|
||||
path and that a specific leaf script should be signed for.
|
||||
*/
|
||||
SIGN_METHOD_TAPROOT_SCRIPT_SPEND = 3;
|
||||
}
|
||||
|
||||
message SignDescriptor {
|
||||
/*
|
||||
A descriptor that precisely describes *which* key to use for signing. This
|
||||
@@ -209,12 +235,23 @@ message SignDescriptor {
|
||||
*/
|
||||
bytes double_tweak = 3;
|
||||
|
||||
/*
|
||||
The 32 byte input to the taproot tweak derivation that is used to derive
|
||||
the output key from an internal key: outputKey = internalKey +
|
||||
tagged_hash("tapTweak", internalKey || tapTweak).
|
||||
|
||||
When doing a BIP 86 spend, this field can be an empty byte slice.
|
||||
|
||||
When doing a normal key path spend, with the output key committing to an
|
||||
actual script root, then this field should be: the tapscript root hash.
|
||||
*/
|
||||
bytes tap_tweak = 10;
|
||||
|
||||
/*
|
||||
The full script required to properly redeem the output. This field will
|
||||
only be populated if a p2tr, p2wsh or a p2sh output is being signed. In case
|
||||
taproot_key_spend is set to true then this value must correspond to the
|
||||
taproot root hash (in case of a tapscript output) or the tap hashed internal
|
||||
public key (in case of a BIP-0086 output).
|
||||
only be populated if a p2tr, p2wsh or a p2sh output is being signed. If a
|
||||
taproot script path spend is being attempted, then this should be the raw
|
||||
leaf script.
|
||||
*/
|
||||
bytes witness_script = 4;
|
||||
|
||||
@@ -236,12 +273,12 @@ message SignDescriptor {
|
||||
int32 input_index = 8;
|
||||
|
||||
/*
|
||||
Indicates that this should produce a signature that can be used for the key
|
||||
spend path of a taproot input. This requires the witness_script field to be
|
||||
set to the taproot root hash (in case of a tapscript output) or the tap
|
||||
hashed internal public key (in case of a BIP-0086 output).
|
||||
The sign method specifies how the input should be signed. Depending on the
|
||||
method, either the tap_tweak, witness_script or both need to be specified.
|
||||
Defaults to SegWit v0 signing to be backward compatible with older RPC
|
||||
clients.
|
||||
*/
|
||||
bool taproot_key_spend = 9;
|
||||
SignMethod sign_method = 9;
|
||||
}
|
||||
|
||||
message SignReq {
|
||||
|
||||
Reference in new issue
Block a user