Skip to content

Commit cf723d6

Browse files
committed
rfqmsg: add noop option to HTLC
We add a new noop flag to the HTLC which, when set, will produce the corresponding TLV record. We also hide this feature behind the dev flag, as we ultimately want to be backwards compatible via some feature bit related peer messages.
1 parent 32474af commit cf723d6

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

rfqmsg/noop_add_active.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build dev
2+
3+
package rfqmsg
4+
5+
// SetNoopAdd flags the HTLC as a noop_add.
6+
func (h *Htlc) SetNoopAdd() {
7+
h.NoopAdd = true
8+
}

rfqmsg/noop_add_inactive.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build !dev
2+
3+
package rfqmsg
4+
5+
// SetNoopAdd flags the HTLC as a noop_add.
6+
func (h *Htlc) SetNoopAdd() {}

rfqmsg/records.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/lightninglabs/taproot-assets/asset"
1313
"github.com/lightninglabs/taproot-assets/fn"
1414
"github.com/lightninglabs/taproot-assets/rfqmath"
15+
"github.com/lightningnetwork/lnd/lnwallet"
1516
"github.com/lightningnetwork/lnd/lnwire"
1617
"github.com/lightningnetwork/lnd/tlv"
1718
)
@@ -59,6 +60,13 @@ type Htlc struct {
5960

6061
// RfqID is the RFQ ID that corresponds to the HTLC.
6162
RfqID tlv.OptionalRecordT[HtlcRfqIDType, ID]
63+
64+
// NoopAdd is a flag that indicates whether this HTLC should be marked
65+
// as a noop_add for LND. A noop_add HTLC behaves identically to a
66+
// normal HTLC except for the settlement step, where the satoshi amount
67+
// is returned back to the sender, but the commitment blob is still
68+
// updated to reflect the asset balance changes.
69+
NoopAdd bool
6270
}
6371

6472
// NewHtlc creates a new Htlc record with the given funded assets.
@@ -135,6 +143,11 @@ func (h *Htlc) Records() []tlv.Record {
135143
records = append(records, r.Record())
136144
})
137145

146+
if h.NoopAdd {
147+
r := tlv.NewPrimitiveRecord[lnwallet.NoopAddHtlcType](true)
148+
records = append(records, r.Record())
149+
}
150+
138151
return records
139152
}
140153

0 commit comments

Comments
 (0)