Skip to content

Commit beffd3b

Browse files
committed
tapchannel: pass in cltvLock time when making 2nd level sweep vpkts
1 parent fafe604 commit beffd3b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tapchannel/aux_sweeper.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,26 @@ func (a *AuxSweeper) createSweepVpackets(sweepInputs []*cmsg.AssetOutput,
206206
// the output information locked in, as this was a pre-signed
207207
// transaction.
208208
if sweepDesc.auxSigInfo.IsSome() {
209+
log.Infof("Re-creating second level HTLC vPkt to "+
210+
"spend: %v", resReq.ContractPoint)
211+
212+
var cltvTimeout fn.Option[uint32]
213+
sweepDesc.absoluteDelay.WhenSome(func(delay uint64) {
214+
cltvTimeout = fn.Some(uint32(delay))
215+
})
216+
217+
// When we create the 2nd level allocation, we set the output
218+
// index to be None, as we don't know exactly _where_ on the
219+
// sweep transaction this output will lie.
209220
alloc, err := createSecondLevelHtlcAllocations(
210221
resReq.ChanType, resReq.Initiator, sweepInputs,
211222
resReq.HtlcAmt, resReq.CommitCsvDelay, *resReq.KeyRing,
212-
fn.Some(resReq.ContractPoint.Index),
223+
fn.None[uint32](), cltvTimeout,
213224
)
214225
if err != nil {
215226
return lfn.Err[returnType](err)
216227
}
217228

218-
// TODO(roasbeef): allocation needs precise output index set?
219-
220229
allocs = append(allocs, alloc...)
221230
} else {
222231
// Otherwise, for each out we want to sweep, we'll construct an

0 commit comments

Comments
 (0)