Skip to content

Commit 5f22a95

Browse files
committed
lnwallet: add noop updateType to paymendDescriptor
We add a new update type to the payment descriptor to describe this new type of htlc. We also add the isAdd helper as the two HTLC add types are almost identical except for the settling part.
1 parent d7f6f35 commit 5f22a95

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lnwallet/payment_descriptor.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ const (
4242
// FeeUpdate is an update type sent by the channel initiator that
4343
// updates the fee rate used when signing the commitment transaction.
4444
FeeUpdate
45+
46+
// NoopAdd is an update type that adds a new HTLC entry into the log.
47+
// This differs from the normal Add type, in that when settled the
48+
// balance will go back to the sender, rather than be credited for the
49+
// receiver.
50+
NoopAdd
4551
)
4652

4753
// String returns a human readable string that uniquely identifies the target
@@ -58,6 +64,8 @@ func (u updateType) String() string {
5864
return "Settle"
5965
case FeeUpdate:
6066
return "FeeUpdate"
67+
case NoopAdd:
68+
return "NoopAdd"
6169
default:
6270
return "<unknown type>"
6371
}
@@ -238,7 +246,7 @@ type paymentDescriptor struct {
238246
func (pd *paymentDescriptor) toLogUpdate() channeldb.LogUpdate {
239247
var msg lnwire.Message
240248
switch pd.EntryType {
241-
case Add:
249+
case Add, NoopAdd:
242250
msg = &lnwire.UpdateAddHTLC{
243251
ChanID: pd.ChanID,
244252
ID: pd.HtlcIndex,
@@ -290,7 +298,7 @@ func (pd *paymentDescriptor) setCommitHeight(
290298
whoseCommitChain lntypes.ChannelParty, nextHeight uint64) {
291299

292300
switch pd.EntryType {
293-
case Add:
301+
case Add, NoopAdd:
294302
pd.addCommitHeights.SetForParty(
295303
whoseCommitChain, nextHeight,
296304
)
@@ -311,3 +319,8 @@ func (pd *paymentDescriptor) setCommitHeight(
311319
)
312320
}
313321
}
322+
323+
// isAdd returns true if the paymentDescriptor is of type Add.
324+
func (pd *paymentDescriptor) isAdd() bool {
325+
return pd.EntryType == Add || pd.EntryType == NoopAdd
326+
}

0 commit comments

Comments
 (0)