lnwallet+nursery+input: set sequence=1 for direct HTLC spends
This commit is contained in:
parent
c5d58b4762
commit
92af2342da
@ -118,6 +118,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
&h.htlcResolution.SweepSignDesc,
|
&h.htlcResolution.SweepSignDesc,
|
||||||
h.htlcResolution.Preimage[:],
|
h.htlcResolution.Preimage[:],
|
||||||
h.broadcastHeight,
|
h.broadcastHeight,
|
||||||
|
h.htlcResolution.CsvDelay,
|
||||||
)
|
)
|
||||||
|
|
||||||
// With the input created, we can now generate the full
|
// With the input created, we can now generate the full
|
||||||
|
@ -156,8 +156,8 @@ type HtlcSucceedInput struct {
|
|||||||
// MakeHtlcSucceedInput assembles a new redeem input that can be used to
|
// MakeHtlcSucceedInput assembles a new redeem input that can be used to
|
||||||
// construct a sweep transaction.
|
// construct a sweep transaction.
|
||||||
func MakeHtlcSucceedInput(outpoint *wire.OutPoint,
|
func MakeHtlcSucceedInput(outpoint *wire.OutPoint,
|
||||||
signDescriptor *SignDescriptor,
|
signDescriptor *SignDescriptor, preimage []byte, heightHint,
|
||||||
preimage []byte, heightHint uint32) HtlcSucceedInput {
|
blocksToMaturity uint32) HtlcSucceedInput {
|
||||||
|
|
||||||
return HtlcSucceedInput{
|
return HtlcSucceedInput{
|
||||||
inputKit: inputKit{
|
inputKit: inputKit{
|
||||||
@ -165,6 +165,7 @@ func MakeHtlcSucceedInput(outpoint *wire.OutPoint,
|
|||||||
witnessType: HtlcAcceptedRemoteSuccess,
|
witnessType: HtlcAcceptedRemoteSuccess,
|
||||||
signDesc: *signDescriptor,
|
signDesc: *signDescriptor,
|
||||||
heightHint: heightHint,
|
heightHint: heightHint,
|
||||||
|
blockToMaturity: blocksToMaturity,
|
||||||
},
|
},
|
||||||
preimage: preimage,
|
preimage: preimage,
|
||||||
}
|
}
|
||||||
|
@ -5253,7 +5253,8 @@ type IncomingHtlcResolution struct {
|
|||||||
// pass after the SignedSuccessTx is confirmed in the chain before the
|
// pass after the SignedSuccessTx is confirmed in the chain before the
|
||||||
// output can be swept.
|
// output can be swept.
|
||||||
//
|
//
|
||||||
// NOTE: If SignedSuccessTx is nil, then this field isn't needed.
|
// NOTE: If SignedTimeoutTx is nil, then this field denotes the CSV
|
||||||
|
// delay needed to spend from the commitment transaction.
|
||||||
CsvDelay uint32
|
CsvDelay uint32
|
||||||
|
|
||||||
// ClaimOutpoint is the final outpoint that needs to be spent in order
|
// ClaimOutpoint is the final outpoint that needs to be spent in order
|
||||||
@ -5293,7 +5294,8 @@ type OutgoingHtlcResolution struct {
|
|||||||
// pass after the SignedTimeoutTx is confirmed in the chain before the
|
// pass after the SignedTimeoutTx is confirmed in the chain before the
|
||||||
// output can be swept.
|
// output can be swept.
|
||||||
//
|
//
|
||||||
// NOTE: If SignedTimeoutTx is nil, then this field isn't needed.
|
// NOTE: If SignedTimeoutTx is nil, then this field denotes the CSV
|
||||||
|
// delay needed to spend from the commitment transaction.
|
||||||
CsvDelay uint32
|
CsvDelay uint32
|
||||||
|
|
||||||
// ClaimOutpoint is the final outpoint that needs to be spent in order
|
// ClaimOutpoint is the final outpoint that needs to be spent in order
|
||||||
@ -5366,6 +5368,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
|
|||||||
},
|
},
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
},
|
},
|
||||||
|
CsvDelay: HtlcSecondLevelInputSequence(chanType),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5487,7 +5490,6 @@ func newIncomingHtlcResolution(signer input.Signer,
|
|||||||
// SignDescriptor needed to sweep the output.
|
// SignDescriptor needed to sweep the output.
|
||||||
return &IncomingHtlcResolution{
|
return &IncomingHtlcResolution{
|
||||||
ClaimOutpoint: op,
|
ClaimOutpoint: op,
|
||||||
CsvDelay: csvDelay,
|
|
||||||
SweepSignDesc: input.SignDescriptor{
|
SweepSignDesc: input.SignDescriptor{
|
||||||
KeyDesc: localChanCfg.HtlcBasePoint,
|
KeyDesc: localChanCfg.HtlcBasePoint,
|
||||||
SingleTweak: keyRing.LocalHtlcKeyTweak,
|
SingleTweak: keyRing.LocalHtlcKeyTweak,
|
||||||
@ -5498,6 +5500,7 @@ func newIncomingHtlcResolution(signer input.Signer,
|
|||||||
},
|
},
|
||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
},
|
},
|
||||||
|
CsvDelay: HtlcSecondLevelInputSequence(chanType),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,10 +397,11 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint,
|
|||||||
|
|
||||||
// Otherwise, this is actually a kid output as we can sweep it
|
// Otherwise, this is actually a kid output as we can sweep it
|
||||||
// once the commitment transaction confirms, and the absolute
|
// once the commitment transaction confirms, and the absolute
|
||||||
// CLTV lock has expired. We set the CSV delay to zero to
|
// CLTV lock has expired. We set the CSV delay what the
|
||||||
// indicate this is actually a CLTV output.
|
// resolution encodes, since the sequence number must be set
|
||||||
|
// accordingly.
|
||||||
htlcOutput := makeKidOutput(
|
htlcOutput := makeKidOutput(
|
||||||
&htlcRes.ClaimOutpoint, &chanPoint, 0,
|
&htlcRes.ClaimOutpoint, &chanPoint, htlcRes.CsvDelay,
|
||||||
input.HtlcOfferedRemoteTimeout,
|
input.HtlcOfferedRemoteTimeout,
|
||||||
&htlcRes.SweepSignDesc, htlcRes.Expiry,
|
&htlcRes.SweepSignDesc, htlcRes.Expiry,
|
||||||
)
|
)
|
||||||
@ -1271,7 +1272,8 @@ type kidOutput struct {
|
|||||||
// output.
|
// output.
|
||||||
//
|
//
|
||||||
// NOTE: This will be set for: commitment outputs, and incoming HTLC's.
|
// NOTE: This will be set for: commitment outputs, and incoming HTLC's.
|
||||||
// Otherwise, this will be zero.
|
// Otherwise, this will be zero. It will also be non-zero for
|
||||||
|
// commitment types which requires confirmed spends.
|
||||||
blocksToMaturity uint32
|
blocksToMaturity uint32
|
||||||
|
|
||||||
// absoluteMaturity is the absolute height that this output will be
|
// absoluteMaturity is the absolute height that this output will be
|
||||||
|
@ -603,7 +603,6 @@ func createOutgoingRes(onLocalCommitment bool) *lnwallet.OutgoingHtlcResolution
|
|||||||
Value: 10000,
|
Value: 10000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CsvDelay: 2,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if onLocalCommitment {
|
if onLocalCommitment {
|
||||||
@ -620,8 +619,10 @@ func createOutgoingRes(onLocalCommitment bool) *lnwallet.OutgoingHtlcResolution
|
|||||||
}
|
}
|
||||||
|
|
||||||
outgoingRes.SignedTimeoutTx = timeoutTx
|
outgoingRes.SignedTimeoutTx = timeoutTx
|
||||||
|
outgoingRes.CsvDelay = 2
|
||||||
} else {
|
} else {
|
||||||
outgoingRes.ClaimOutpoint = htlcOp
|
outgoingRes.ClaimOutpoint = htlcOp
|
||||||
|
outgoingRes.CsvDelay = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return &outgoingRes
|
return &outgoingRes
|
||||||
|
Loading…
Reference in New Issue
Block a user