lnwallet+breacharbiter: record local csv delay

This commit is contained in:
Johan T. Halseth
2020-03-06 16:11:47 +01:00
parent 92af2342da
commit ad8e9f30c6
2 changed files with 25 additions and 6 deletions

View File

@@ -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(),
})
}