mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
lnwallet+breacharbiter: record local csv delay
This commit is contained in:
parent
92af2342da
commit
ad8e9f30c6
@ -896,6 +896,13 @@ func (bo *breachedOutput) CraftInputScript(signer input.Signer, txn *wire.MsgTx,
|
||||
// must be built on top of the confirmation height before the output can be
|
||||
// spent.
|
||||
func (bo *breachedOutput) BlocksToMaturity() uint32 {
|
||||
// If the output is a to_remote output we can claim, and it's of the
|
||||
// confirmed type, we must wait one block before claiming it.
|
||||
if bo.witnessType == input.CommitmentToRemoteConfirmed {
|
||||
return 1
|
||||
}
|
||||
|
||||
// All other breached outputs have no CSV delay.
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -952,6 +959,12 @@ func newRetributionInfo(chanPoint *wire.OutPoint,
|
||||
witnessType = input.CommitSpendNoDelayTweakless
|
||||
}
|
||||
|
||||
// If the local delay is non-zero, it means this output is of
|
||||
// the confirmed to_remote type.
|
||||
if breachInfo.LocalDelay != 0 {
|
||||
witnessType = input.CommitmentToRemoteConfirmed
|
||||
}
|
||||
|
||||
localOutput := makeBreachedOutput(
|
||||
&breachInfo.LocalOutpoint,
|
||||
witnessType,
|
||||
@ -1117,6 +1130,7 @@ func (b *breachArbiter) sweepSpendableOutputsTxn(txWeight int64,
|
||||
for _, input := range inputs {
|
||||
txn.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: *input.OutPoint(),
|
||||
Sequence: input.BlocksToMaturity(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2013,6 +2013,10 @@ type BreachRetribution struct {
|
||||
// party) within the breach transaction.
|
||||
LocalOutpoint wire.OutPoint
|
||||
|
||||
// LocalDelay is the CSV delay for the to_remote script on the breached
|
||||
// commitment.
|
||||
LocalDelay uint32
|
||||
|
||||
// RemoteOutputSignDesc is a SignDescriptor which is capable of
|
||||
// generating the signature required to claim the funds as described
|
||||
// within the revocation clause of the remote party's commitment
|
||||
@ -2026,6 +2030,10 @@ type BreachRetribution struct {
|
||||
// party within the breach transaction.
|
||||
RemoteOutpoint wire.OutPoint
|
||||
|
||||
// RemoteDelay specifies the CSV delay applied to to-local scripts on
|
||||
// the breaching commitment transaction.
|
||||
RemoteDelay uint32
|
||||
|
||||
// HtlcRetributions is a slice of HTLC retributions for each output
|
||||
// active HTLC output within the breached commitment transaction.
|
||||
HtlcRetributions []HtlcRetribution
|
||||
@ -2034,10 +2042,6 @@ type BreachRetribution struct {
|
||||
// breaching commitment transaction. This allows downstream clients to
|
||||
// have access to the public keys used in the scripts.
|
||||
KeyRing *CommitmentKeyRing
|
||||
|
||||
// RemoteDelay specifies the CSV delay applied to to-local scripts on
|
||||
// the breaching commitment transaction.
|
||||
RemoteDelay uint32
|
||||
}
|
||||
|
||||
// NewBreachRetribution creates a new fully populated BreachRetribution for the
|
||||
@ -2090,7 +2094,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
||||
|
||||
// Since it is the remote breach we are reconstructing, the output going
|
||||
// to us will be a to-remote script with our local params.
|
||||
ourScript, _, err := CommitScriptToRemote(
|
||||
ourScript, ourDelay, err := CommitScriptToRemote(
|
||||
chanState.ChanType, keyRing.ToRemoteKey,
|
||||
)
|
||||
if err != nil {
|
||||
@ -2226,11 +2230,12 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
|
||||
PendingHTLCs: revokedSnapshot.Htlcs,
|
||||
LocalOutpoint: ourOutpoint,
|
||||
LocalOutputSignDesc: ourSignDesc,
|
||||
LocalDelay: ourDelay,
|
||||
RemoteOutpoint: theirOutpoint,
|
||||
RemoteOutputSignDesc: theirSignDesc,
|
||||
RemoteDelay: theirDelay,
|
||||
HtlcRetributions: htlcRetributions,
|
||||
KeyRing: keyRing,
|
||||
RemoteDelay: theirDelay,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user