mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
lnwallet: ensure CSV delay witness spend uses a minimal OP_IF
This commit fixes a slight scripting related issue as a result of default policy in Bitcoin Core 0.13.1. With this version of Bitcoin Core, nodes will now enforce a policy that ensures the first argument of OP_IF is either an empty vector or a 0x01 value. Our current sent of functions to generate the witness for the delay clause of the commitment transaction instead uses a 0x00 value rather than an empty byte vector. With this commit we fix the issue by ensuring that we use an empty vector rather an 0x00 for forcing the commitment delay script pathway.
This commit is contained in:
parent
9cef2f8657
commit
a393362eb8
@ -554,7 +554,7 @@ func lockTimeToSequence(isSeconds bool, locktime uint32) uint32 {
|
||||
//
|
||||
// Possible Input Scripts:
|
||||
// REVOKE: <sig> 1
|
||||
// SENDRSWEEP: <sig> 0
|
||||
// SENDRSWEEP: <sig> <emptyvector>
|
||||
//
|
||||
// Output Script:
|
||||
// OP_IF
|
||||
@ -630,11 +630,13 @@ func CommitSpendTimeout(signer Signer, signDesc *SignDescriptor,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Place a zero as the first item in the evaluated witness stack to
|
||||
// force script execution to the timeout spend clause.
|
||||
// Place an empty byte as the first item in the evaluated witness stack
|
||||
// to force script execution to the timeout spend clause. We need to
|
||||
// place an empty byte in order to ensure our script is still valid
|
||||
// from the PoV of nodes that are enforcing minimal OP_IF/OP_NOTIF.
|
||||
witnessStack := wire.TxWitness(make([][]byte, 3))
|
||||
witnessStack[0] = append(sweepSig, byte(txscript.SigHashAll))
|
||||
witnessStack[1] = []byte{0}
|
||||
witnessStack[1] = nil
|
||||
witnessStack[2] = signDesc.WitnessScript
|
||||
|
||||
return witnessStack, nil
|
||||
|
Loading…
Reference in New Issue
Block a user