Skip to content

Commit 85b5903

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 023b702 commit 85b5903

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,6 @@ github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3 h1:NuDp6Z+QNM
11441144
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3/go.mod h1:bDnEKRN1u13NFBuy/C+bFLhxA5bfd3clT25y76QY0AM=
11451145
github.com/lightninglabs/lightning-node-connect/mailbox v1.0.1 h1:RWmohykp3n/DTMWY8b18RNTEcLDf+KT/AZHKYdOObkM=
11461146
github.com/lightninglabs/lightning-node-connect/mailbox v1.0.1/go.mod h1:NYtNexZE9gO1eOeegTxmIW9fqanl7eZ9cOrE9yewSAk=
1147-
github.com/lightninglabs/lndclient v0.19.0-9 h1:ell27omDoks79upoAsO/7QY40O93ud4tAtBXXZilqok=
1148-
github.com/lightninglabs/lndclient v0.19.0-9/go.mod h1:35d50tEMFxlJlKTZGYA6EdOllPsbxS4FUmEVbETUx+Q=
11491147
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2 h1:eFjp1dIB2BhhQp/THKrjLdlYuPugO9UU4kDqu91OX/Q=
11501148
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2/go.mod h1:99BKpIi6ruaaXRM1A77eqZ+FWPQ3cfRa+ZVy5bmWMaY=
11511149
github.com/lightninglabs/neutrino v0.16.1 h1:5Kz4ToxncEVkpKC6fwUjXKtFKJhuxlG3sBB3MdJTJjs=

rfqmsg/aux_features.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build !dev
2+
3+
package rfqmsg
4+
5+
var (
6+
// UseNoOpHTLCs is set to false, as we don't want to enable it for
7+
// production builds.
8+
UseNoOpHTLCs = false
9+
)

rfqmsg/aux_features_dev.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+
var (
6+
// UseNoOpHTLCs is set to true, as we want to enable it for dev builds.
7+
UseNoOpHTLCs = true
8+
)

rfqmsg/records.go

Lines changed: 18 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
)
@@ -169,6 +170,13 @@ type Htlc struct {
169170
// picked when an HTLC is sent over to a peer. When one of these RFQ IDs
170171
// gets picked it will be encoded as an Htlc.RfqID (see above field).
171172
AvailableRfqIDs tlv.OptionalRecordT[AvailableRfqIDsType, HtlcRfqIDs]
173+
174+
// NoopAdd is a flag that indicates whether this HTLC should be marked
175+
// as a noop_add for LND. A noop_add HTLC behaves identically to a
176+
// normal HTLC except for the settlement step, where the satoshi amount
177+
// is returned back to the sender, but the commitment blob is still
178+
// updated to reflect the asset balance changes.
179+
NoopAdd bool
172180
}
173181

174182
// NewHtlc creates a new Htlc record with the given funded assets.
@@ -258,9 +266,19 @@ func (h *Htlc) Records() []tlv.Record {
258266
},
259267
)
260268

269+
if h.NoopAdd {
270+
r := tlv.NewPrimitiveRecord[lnwallet.NoOpHtlcTLVType](true)
271+
records = append(records, r.Record())
272+
}
273+
261274
return records
262275
}
263276

277+
// SetNoopAdd flags the HTLC as a noop_add.
278+
func (h *Htlc) SetNoopAdd(noopActive bool) {
279+
h.NoopAdd = noopActive
280+
}
281+
264282
// Encode serializes the Htlc to the given io.Writer.
265283
func (h *Htlc) Encode(w io.Writer) error {
266284
tlvRecords := h.Records()

0 commit comments

Comments
 (0)