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:
Olaoluwa Osuntokun 2017-07-30 20:23:24 -07:00
parent e840f43db4
commit d4a5eaa6ad
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -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