lnwallet: set 2nd level sequence according to channel type
This commit is contained in:
parent
bddd3e128c
commit
c5d58b4762
@ -235,6 +235,16 @@ func HtlcSigHashType(chanType channeldb.ChannelType) txscript.SigHashType {
|
|||||||
return txscript.SigHashAll
|
return txscript.SigHashAll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HtlcSecondLevelInputSequence dictates the sequence number we must use on the
|
||||||
|
// input to a second level HTLC transaction.
|
||||||
|
func HtlcSecondLevelInputSequence(chanType channeldb.ChannelType) uint32 {
|
||||||
|
if chanType.HasAnchors() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// CommitWeight returns the base commitment weight before adding HTLCs.
|
// CommitWeight returns the base commitment weight before adding HTLCs.
|
||||||
func CommitWeight(chanType channeldb.ChannelType) int64 {
|
func CommitWeight(chanType channeldb.ChannelType) int64 {
|
||||||
// If this commitment has anchors, it will be slightly heavier.
|
// If this commitment has anchors, it will be slightly heavier.
|
||||||
|
@ -54,10 +54,13 @@ func createHtlcSuccessTx(chanType channeldb.ChannelType,
|
|||||||
successTx := wire.NewMsgTx(2)
|
successTx := wire.NewMsgTx(2)
|
||||||
|
|
||||||
// The input to the transaction is the outpoint that creates the
|
// The input to the transaction is the outpoint that creates the
|
||||||
// original HTLC on the sender's commitment transaction.
|
// original HTLC on the sender's commitment transaction. Set the
|
||||||
successTx.AddTxIn(&wire.TxIn{
|
// sequence number based on the channel type.
|
||||||
|
txin := &wire.TxIn{
|
||||||
PreviousOutPoint: htlcOutput,
|
PreviousOutPoint: htlcOutput,
|
||||||
})
|
Sequence: HtlcSecondLevelInputSequence(chanType),
|
||||||
|
}
|
||||||
|
successTx.AddTxIn(txin)
|
||||||
|
|
||||||
// Next, we'll generate the script used as the output for all second
|
// Next, we'll generate the script used as the output for all second
|
||||||
// level HTLC which forces a covenant w.r.t what can be done with all
|
// level HTLC which forces a covenant w.r.t what can be done with all
|
||||||
@ -110,10 +113,13 @@ func createHtlcTimeoutTx(chanType channeldb.ChannelType,
|
|||||||
timeoutTx.LockTime = cltvExpiry
|
timeoutTx.LockTime = cltvExpiry
|
||||||
|
|
||||||
// The input to the transaction is the outpoint that creates the
|
// The input to the transaction is the outpoint that creates the
|
||||||
// original HTLC on the sender's commitment transaction.
|
// original HTLC on the sender's commitment transaction. Set the
|
||||||
timeoutTx.AddTxIn(&wire.TxIn{
|
// sequence number based on the channel type.
|
||||||
|
txin := &wire.TxIn{
|
||||||
PreviousOutPoint: htlcOutput,
|
PreviousOutPoint: htlcOutput,
|
||||||
})
|
Sequence: HtlcSecondLevelInputSequence(chanType),
|
||||||
|
}
|
||||||
|
timeoutTx.AddTxIn(txin)
|
||||||
|
|
||||||
// Next, we'll generate the script used as the output for all second
|
// Next, we'll generate the script used as the output for all second
|
||||||
// level HTLC which forces a covenant w.r.t what can be done with all
|
// level HTLC which forces a covenant w.r.t what can be done with all
|
||||||
|
Loading…
Reference in New Issue
Block a user