mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 22:21:18 +02:00
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.
This commit is contained in:
@@ -99,17 +99,6 @@ func (h *htlcIncomingContestResolver) Resolve(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the HTLC has custom records, then for now we'll pause resolution.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): Implement resolving HTLCs with custom records
|
|
||||||
// (follow-up PR).
|
|
||||||
if len(h.htlc.CustomRecords) != 0 {
|
|
||||||
select { //nolint:gosimple
|
|
||||||
case <-h.quit:
|
|
||||||
return nil, errResolverShuttingDown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// First try to parse the payload. If that fails, we can stop resolution
|
// First try to parse the payload. If that fails, we can stop resolution
|
||||||
// now.
|
// now.
|
||||||
payload, nextHopOnionBlob, err := h.decodePayload()
|
payload, nextHopOnionBlob, err := h.decodePayload()
|
||||||
|
@@ -6,7 +6,9 @@ import (
|
|||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// htlcLeaseResolver is a struct that houses the lease specific HTLC resolution
|
// htlcLeaseResolver is a struct that houses the lease specific HTLC resolution
|
||||||
@@ -52,8 +54,8 @@ func (h *htlcLeaseResolver) deriveWaitHeight(csvDelay uint32,
|
|||||||
// send to the sweeper so the output can ultimately be swept.
|
// send to the sweeper so the output can ultimately be swept.
|
||||||
func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
|
func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
|
||||||
wType, cltvWtype input.StandardWitnessType,
|
wType, cltvWtype input.StandardWitnessType,
|
||||||
signDesc *input.SignDescriptor,
|
signDesc *input.SignDescriptor, csvDelay, broadcastHeight uint32,
|
||||||
csvDelay, broadcastHeight uint32, payHash [32]byte) *input.BaseInput {
|
payHash [32]byte, resBlob fn.Option[tlv.Blob]) *input.BaseInput {
|
||||||
|
|
||||||
if h.hasCLTV() {
|
if h.hasCLTV() {
|
||||||
log.Infof("%T(%x): CSV and CLTV locks expired, offering "+
|
log.Infof("%T(%x): CSV and CLTV locks expired, offering "+
|
||||||
@@ -63,13 +65,17 @@ func (h *htlcLeaseResolver) makeSweepInput(op *wire.OutPoint,
|
|||||||
op, cltvWtype, signDesc,
|
op, cltvWtype, signDesc,
|
||||||
broadcastHeight, csvDelay,
|
broadcastHeight, csvDelay,
|
||||||
h.leaseExpiry,
|
h.leaseExpiry,
|
||||||
|
input.WithResolutionBlob(resBlob),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("%T(%x): CSV lock expired, offering second-layer output to "+
|
log.Infof("%T(%x): CSV lock expired, offering second-layer output to "+
|
||||||
"sweeper: %v", h, payHash, op)
|
"sweeper: %v", h, payHash, op)
|
||||||
|
|
||||||
return input.NewCsvInput(op, wType, signDesc, broadcastHeight, csvDelay)
|
return input.NewCsvInput(
|
||||||
|
op, wType, signDesc, broadcastHeight, csvDelay,
|
||||||
|
input.WithResolutionBlob(resBlob),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SupplementState allows the user of a ContractResolver to supplement it with
|
// SupplementState allows the user of a ContractResolver to supplement it with
|
||||||
|
@@ -58,17 +58,6 @@ func (h *htlcOutgoingContestResolver) Resolve(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the HTLC has custom records, then for now we'll pause resolution.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): Implement resolving HTLCs with custom records
|
|
||||||
// (follow-up PR).
|
|
||||||
if len(h.htlc.CustomRecords) != 0 {
|
|
||||||
select { //nolint:gosimple
|
|
||||||
case <-h.quit:
|
|
||||||
return nil, errResolverShuttingDown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, we'll watch for two external signals to decide if we'll
|
// Otherwise, we'll watch for two external signals to decide if we'll
|
||||||
// morph into another resolver, or fully resolve the contract.
|
// morph into another resolver, or fully resolve the contract.
|
||||||
//
|
//
|
||||||
|
@@ -123,17 +123,6 @@ func (h *htlcSuccessResolver) Resolve(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the HTLC has custom records, then for now we'll pause resolution.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): Implement resolving HTLCs with custom records
|
|
||||||
// (follow-up PR).
|
|
||||||
if len(h.htlc.CustomRecords) != 0 {
|
|
||||||
select { //nolint:gosimple
|
|
||||||
case <-h.quit:
|
|
||||||
return nil, errResolverShuttingDown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't have a success transaction, then this means that this is
|
// If we don't have a success transaction, then this means that this is
|
||||||
// an output on the remote party's commitment transaction.
|
// an output on the remote party's commitment transaction.
|
||||||
if h.htlcResolution.SignedSuccessTx == nil {
|
if h.htlcResolution.SignedSuccessTx == nil {
|
||||||
@@ -258,6 +247,9 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
|
|||||||
h.htlcResolution.SignedSuccessTx,
|
h.htlcResolution.SignedSuccessTx,
|
||||||
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
h.htlcResolution.SignDetails, h.htlcResolution.Preimage,
|
||||||
h.broadcastHeight,
|
h.broadcastHeight,
|
||||||
|
input.WithResolutionBlob(
|
||||||
|
h.htlcResolution.ResolutionBlob,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
@@ -414,7 +406,7 @@ func (h *htlcSuccessResolver) broadcastReSignedSuccessTx(immediate bool) (
|
|||||||
input.LeaseHtlcAcceptedSuccessSecondLevel,
|
input.LeaseHtlcAcceptedSuccessSecondLevel,
|
||||||
&h.htlcResolution.SweepSignDesc,
|
&h.htlcResolution.SweepSignDesc,
|
||||||
h.htlcResolution.CsvDelay, uint32(commitSpend.SpendingHeight),
|
h.htlcResolution.CsvDelay, uint32(commitSpend.SpendingHeight),
|
||||||
h.htlc.RHash,
|
h.htlc.RHash, h.htlcResolution.ResolutionBlob,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Calculate the budget for this sweep.
|
// Calculate the budget for this sweep.
|
||||||
@@ -470,6 +462,9 @@ func (h *htlcSuccessResolver) resolveRemoteCommitOutput(immediate bool) (
|
|||||||
h.htlcResolution.Preimage[:],
|
h.htlcResolution.Preimage[:],
|
||||||
h.broadcastHeight,
|
h.broadcastHeight,
|
||||||
h.htlcResolution.CsvDelay,
|
h.htlcResolution.CsvDelay,
|
||||||
|
input.WithResolutionBlob(
|
||||||
|
h.htlcResolution.ResolutionBlob,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
inp = lnutils.Ptr(input.MakeHtlcSucceedInput(
|
inp = lnutils.Ptr(input.MakeHtlcSucceedInput(
|
||||||
|
@@ -426,17 +426,6 @@ func (h *htlcTimeoutResolver) Resolve(
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the HTLC has custom records, then for now we'll pause resolution.
|
|
||||||
//
|
|
||||||
// TODO(roasbeef): Implement resolving HTLCs with custom records
|
|
||||||
// (follow-up PR).
|
|
||||||
if len(h.htlc.CustomRecords) != 0 {
|
|
||||||
select { //nolint:gosimple
|
|
||||||
case <-h.quit:
|
|
||||||
return nil, errResolverShuttingDown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start by spending the HTLC output, either by broadcasting the
|
// Start by spending the HTLC output, either by broadcasting the
|
||||||
// second-level timeout transaction, or directly if this is the remote
|
// second-level timeout transaction, or directly if this is the remote
|
||||||
// commitment.
|
// commitment.
|
||||||
@@ -499,6 +488,9 @@ func (h *htlcTimeoutResolver) sweepSecondLevelTx(immediate bool) error {
|
|||||||
h.htlcResolution.SignedTimeoutTx,
|
h.htlcResolution.SignedTimeoutTx,
|
||||||
h.htlcResolution.SignDetails,
|
h.htlcResolution.SignDetails,
|
||||||
h.broadcastHeight,
|
h.broadcastHeight,
|
||||||
|
input.WithResolutionBlob(
|
||||||
|
h.htlcResolution.ResolutionBlob,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
inp = lnutils.Ptr(input.MakeHtlcSecondLevelTimeoutAnchorInput(
|
inp = lnutils.Ptr(input.MakeHtlcSecondLevelTimeoutAnchorInput(
|
||||||
@@ -592,6 +584,7 @@ func (h *htlcTimeoutResolver) sweepDirectHtlcOutput(immediate bool) error {
|
|||||||
&h.htlcResolution.ClaimOutpoint, htlcWitnessType,
|
&h.htlcResolution.ClaimOutpoint, htlcWitnessType,
|
||||||
&h.htlcResolution.SweepSignDesc, h.broadcastHeight,
|
&h.htlcResolution.SweepSignDesc, h.broadcastHeight,
|
||||||
h.htlcResolution.CsvDelay, h.htlcResolution.Expiry,
|
h.htlcResolution.CsvDelay, h.htlcResolution.Expiry,
|
||||||
|
input.WithResolutionBlob(h.htlcResolution.ResolutionBlob),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Calculate the budget.
|
// Calculate the budget.
|
||||||
@@ -846,6 +839,7 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
|
|||||||
&h.htlcResolution.SweepSignDesc,
|
&h.htlcResolution.SweepSignDesc,
|
||||||
h.htlcResolution.CsvDelay,
|
h.htlcResolution.CsvDelay,
|
||||||
uint32(commitSpend.SpendingHeight), h.htlc.RHash,
|
uint32(commitSpend.SpendingHeight), h.htlc.RHash,
|
||||||
|
h.htlcResolution.ResolutionBlob,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Calculate the budget for this sweep.
|
// Calculate the budget for this sweep.
|
||||||
|
Reference in New Issue
Block a user