Skip to content

Commit 83f1c88

Browse files
Roasbeefguggero
authored andcommitted
contractcourt: pass in new aux resolution blob to sweeper in resolvers
With this commit, we update all the resolvers to pass in the new htlc resolution blobs. Along the way, we remove the old blocking guard on this resolution logic for HTLCs with blobs.
1 parent f1a1c03 commit 83f1c88

File tree

5 files changed

+21
-48
lines changed

5 files changed

+21
-48
lines changed

contractcourt/htlc_incoming_contest_resolver.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ func (h *htlcIncomingContestResolver) Resolve(
9999
return nil, nil
100100
}
101101

102-
// If the HTLC has custom records, then for now we'll pause resolution.
103-
//
104-
// TODO(roasbeef): Implement resolving HTLCs with custom records
105-
// (follow-up PR).
106-
if len(h.htlc.CustomRecords) != 0 {
107-
select { //nolint:gosimple
108-
case <-h.quit:
109-
return nil, errResolverShuttingDown
110-
}
111-
}
112-
113102
// First try to parse the payload. If that fails, we can stop resolution
114103
// now.
115104
payload, nextHopOnionBlob, err := h.decodePayload()

contractcourt/htlc_lease_resolver.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"github.com/btcsuite/btcd/wire"
77
"github.com/lightningnetwork/lnd/chainntnfs"
88
"github.com/lightningnetwork/lnd/channeldb"
9+
"github.com/lightningnetwork/lnd/fn"
910
"github.com/lightningnetwork/lnd/input"
11+
"github.com/lightningnetwork/lnd/tlv"
1012
)
1113

1214
// htlcLeaseResolver is a struct that houses the lease specific HTLC resolution
@@ -52,8 +54,8 @@ func (h *htlcLeaseResolver) deriveWaitHeight(csvDelay uint32,
5254
// send to the sweeper so the output can ultimately be swept.
5355
func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
5456
wType, cltvWtype input.StandardWitnessType,
55-
signDesc *input.SignDescriptor,
56-
csvDelay, broadcastHeight uint32, payHash [32]byte) *input.BaseInput {
57+
signDesc *input.SignDescriptor, csvDelay, broadcastHeight uint32,
58+
payHash [32]byte, resBlob fn.Option[tlv.Blob]) *input.BaseInput {
5759

5860
if h.hasCLTV() {
5961
log.Infof("%T(%x): CSV and CLTV locks expired, offering "+
@@ -63,13 +65,17 @@ func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
6365
op, cltvWtype, signDesc,
6466
broadcastHeight, csvDelay,
6567
h.leaseExpiry,
68+
input.WithResolutionBlob(resBlob),
6669
)
6770
}
6871

6972
log.Infof("%T(%x): CSV lock expired, offering second-layer output to "+
7073
"sweeper: %v", h, payHash, op)
7174

72-
return input.NewCsvInput(op, wType, signDesc, broadcastHeight, csvDelay)
75+
return input.NewCsvInput(
76+
op, wType, signDesc, broadcastHeight, csvDelay,
77+
input.WithResolutionBlob(resBlob),
78+
)
7379
}
7480

7581
// SupplementState allows the user of a ContractResolver to supplement it with

contractcourt/htlc_outgoing_contest_resolver.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,6 @@ func (h *htlcOutgoingContestResolver) Resolve(
5858
return nil, nil
5959
}
6060

61-
// If the HTLC has custom records, then for now we'll pause resolution.
62-
//
63-
// TODO(roasbeef): Implement resolving HTLCs with custom records
64-
// (follow-up PR).
65-
if len(h.htlc.CustomRecords) != 0 {
66-
select { //nolint:gosimple
67-
case <-h.quit:
68-
return nil, errResolverShuttingDown
69-
}
70-
}
71-
7261
// Otherwise, we'll watch for two external signals to decide if we'll
7362
// morph into another resolver, or fully resolve the contract.
7463
//

contractcourt/htlc_success_resolver.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,6 @@ func (h *htlcSuccessResolver) Resolve(
123123
return nil, nil
124124
}
125125

126-
// If the HTLC has custom records, then for now we'll pause resolution.
127-
//
128-
// TODO(roasbeef): Implement resolving HTLCs with custom records
129-
// (follow-up PR).
130-
if len(h.htlc.CustomRecords) != 0 {
131-
select { //nolint:gosimple
132-
case <-h.quit:
133-
return nil, errResolverShuttingDown
134-
}
135-
}
136-
137126
// If we don't have a success transaction, then this means that this is
138127
// an output on the remote party's commitment transaction.
139128
if h.htlcResolution.SignedSuccessTx == nil {
@@ -258,6 +247,9 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
258247
h.htlcResolution.SignedSuccessTx,
259248
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
260249
h.broadcastHeight,
250+
input.WithResolutionBlob(
251+
h.htlcResolution.ResolutionBlob,
252+
),
261253
)
262254
} else {
263255
//nolint:lll
@@ -414,7 +406,7 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
414406
input.LeaseHtlcAcceptedSuccessSecondLevel,
415407
&h.htlcResolution.SweepSignDesc,
416408
h.htlcResolution.CsvDelay, uint32(commitSpend.SpendingHeight),
417-
h.htlc.RHash,
409+
h.htlc.RHash, h.htlcResolution.ResolutionBlob,
418410
)
419411

420412
// Calculate the budget for this sweep.
@@ -470,6 +462,9 @@ func (h *htlcSuccessResolver) resolveRemoteCommitOutput(immediate bool) (
470462
h.htlcResolution.Preimage[:],
471463
h.broadcastHeight,
472464
h.htlcResolution.CsvDelay,
465+
input.WithResolutionBlob(
466+
h.htlcResolution.ResolutionBlob,
467+
),
473468
))
474469
} else {
475470
inp = lnutils.Ptr(input.MakeHtlcSucceedInput(

contractcourt/htlc_timeout_resolver.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,17 +426,6 @@ func (h *htlcTimeoutResolver) Resolve(
426426
return nil, nil
427427
}
428428

429-
// If the HTLC has custom records, then for now we'll pause resolution.
430-
//
431-
// TODO(roasbeef): Implement resolving HTLCs with custom records
432-
// (follow-up PR).
433-
if len(h.htlc.CustomRecords) != 0 {
434-
select { //nolint:gosimple
435-
case <-h.quit:
436-
return nil, errResolverShuttingDown
437-
}
438-
}
439-
440429
// Start by spending the HTLC output, either by broadcasting the
441430
// second-level timeout transaction, or directly if this is the remote
442431
// commitment.
@@ -495,6 +484,9 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx(immediate bool) error {
495484
h.htlcResolution.SignedTimeoutTx,
496485
h.htlcResolution.SignDetails,
497486
h.broadcastHeight,
487+
input.WithResolutionBlob(
488+
h.htlcResolution.ResolutionBlob,
489+
),
498490
))
499491
} else {
500492
inp = lnutils.Ptr(input.MakeHtlcSecondLevelTimeoutAnchorInput(
@@ -588,6 +580,7 @@ func (h *htlcTimeoutResolver) sweepDirectHtlcOutput(immediate bool) error {
588580
&h.htlcResolution.ClaimOutpoint, htlcWitnessType,
589581
&h.htlcResolution.SweepSignDesc, h.broadcastHeight,
590582
h.htlcResolution.CsvDelay, h.htlcResolution.Expiry,
583+
input.WithResolutionBlob(h.htlcResolution.ResolutionBlob),
591584
)
592585

593586
// Calculate the budget.
@@ -842,6 +835,7 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
842835
&h.htlcResolution.SweepSignDesc,
843836
h.htlcResolution.CsvDelay,
844837
uint32(commitSpend.SpendingHeight), h.htlc.RHash,
838+
h.htlcResolution.ResolutionBlob,
845839
)
846840

847841
// Calculate the budget for this sweep.

0 commit comments

Comments
 (0)