lnwallet: modify CommitSpendNoDelay to directly craft witness
This commit modifies the CommitSpendNoDelay script witness generation function. We must modify this function as all non-delayed outputs now also require a key derivation. The current default signer.ComputeInputScript implementation is unable to directly look up the public key required as it attempt to target the pub key using the pkScript.
This commit is contained in:
parent
e840f43db4
commit
d4a5eaa6ad
@ -941,12 +941,22 @@ func CommitSpendNoDelay(signer Signer, signDesc *SignDescriptor,
|
||||
|
||||
// This is just a regular p2wkh spend which looks something like:
|
||||
// * witness: <sig> <pubkey>
|
||||
inputScript, err := signer.ComputeInputScript(sweepTx, signDesc)
|
||||
sweepSig, err := signer.SignOutputRaw(sweepTx, signDesc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wire.TxWitness(inputScript.Witness), nil
|
||||
// Finally, we'll manually craft the witness. The witness here is the
|
||||
// exact same as a regular p2wkh witness, but we'll need to ensure that
|
||||
// we use the tweaked public key as the last item in the witness stack
|
||||
// which was originally used to created the pkScript we're spending.
|
||||
witness := make([][]byte, 2)
|
||||
witness[0] = append(sweepSig, byte(txscript.SigHashAll))
|
||||
witness[1] = TweakPubKeyWithTweak(
|
||||
signDesc.PubKey, signDesc.SingleTweak,
|
||||
).SerializeCompressed()
|
||||
|
||||
return witness, nil
|
||||
}
|
||||
|
||||
// SingleTweakBytes computes set of bytes we call the single tweak. The purpose
|
||||
|
Loading…
Reference in New Issue
Block a user