Skip to content

Commit bf350c6

Browse files
committed
lnwallet: expand attributes in ResolutionReq
In this commit, we add some additional attributes to the ResolutionReq struct. These will be used to make sure that we can properly handle all the HTLC variants, on chain. The `AuxSigDesc` will be used to communicate if an HTLC needs to go to the second level or not. It contains the second-level sig information needed to finalize a broadcast to the second level.
1 parent 0876173 commit bf350c6

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

lnwallet/aux_resolutions.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package lnwallet
33
import (
44
"github.com/btcsuite/btcd/btcutil"
55
"github.com/btcsuite/btcd/wire"
6+
"github.com/lightningnetwork/lnd/channeldb"
67
"github.com/lightningnetwork/lnd/fn"
78
"github.com/lightningnetwork/lnd/input"
89
"github.com/lightningnetwork/lnd/lnwire"
@@ -24,13 +25,29 @@ const (
2425
Breach
2526
)
2627

28+
// AuxSigDesc stores optional information related to 2nd level HTLCs for aux
29+
// channels.
30+
type AuxSigDesc struct {
31+
// AuxSig is the second-level signature for the HTLC that we are trying
32+
// to resolve. This is only present if this is a resolution request for
33+
// an HTLC on our commitment transaction.
34+
AuxSig []byte
35+
36+
// SignDetails is the sign details for the second-level HTLC. This may
37+
// be used to generate the second signature needed for broadcast.
38+
SignDetails input.SignDetails
39+
}
40+
2741
// ResolutionReq is used to ask an outside sub-system for additional
2842
// information needed to resolve a contract.
2943
type ResolutionReq struct {
3044
// ChanPoint is the channel point of the channel that we are trying to
3145
// resolve.
3246
ChanPoint wire.OutPoint
3347

48+
// ChanType is the type of the channel that we are trying to resolve.
49+
ChanType channeldb.ChannelType
50+
3451
// ShortChanID is the short channel ID of the channel that we are
3552
// trying to resolve.
3653
ShortChanID lnwire.ShortChannelID
@@ -44,6 +61,13 @@ type ResolutionReq struct {
4461
// FundingBlob is an optional funding blob for the channel.
4562
FundingBlob fn.Option[tlv.Blob]
4663

64+
// HtlcID is the ID of the HTLC that we are trying to resolve. This is
65+
// only set if this is a resolution request for an HTLC.
66+
HtlcID fn.Option[input.HtlcIndex]
67+
68+
// HtlcAmt is the amount of the HTLC that we are trying to resolve.
69+
HtlcAmt btcutil.Amount
70+
4771
// Type is the type of the witness that we are trying to resolve.
4872
Type input.WitnessType
4973

@@ -69,14 +93,26 @@ type ResolutionReq struct {
6993
// CsvDelay is the CSV delay for the local output for this commitment.
7094
CsvDelay uint32
7195

96+
// CommitCsvDelay is the CSV delay for the remote output for this
97+
// commitment.
98+
CommitCsvDelay uint32
99+
72100
// BreachCsvDelay is the CSV delay for the remote output. This is only
73101
// set when the CloseType is Breach. This indicates the CSV delay to
74102
// use for the remote party's to_local delayed output, that is now
75103
// rightfully ours in a breach situation.
76104
BreachCsvDelay fn.Option[uint32]
77105

78-
// CltvDelay is the CLTV delay for the outpoint.
106+
// CltvDelay is the CLTV delay for the outpoint/transaction.
79107
CltvDelay fn.Option[uint32]
108+
109+
// PayHash is the payment hash for the HTLC that we are trying to
110+
// resolve. This is optional as it only applies HTLC outputs.
111+
PayHash fn.Option[[32]byte]
112+
113+
// AuxSigDesc is an optional field that contains additional information
114+
// needed to sweep second level HTLCs.
115+
AuxSigDesc fn.Option[AuxSigDesc]
80116
}
81117

82118
// AuxContractResolver is an interface that is used to resolve contracts that

0 commit comments

Comments
 (0)