Skip to content

Use new NoopAddHtlc TLV when sending assets with default above-dust anchor amt #1567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions rfqmsg/aux_features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !dev

package rfqmsg

var (
// UseNoOpHTLCs is set to false, as we don't want to enable it for
// production builds.
UseNoOpHTLCs = false
)
8 changes: 8 additions & 0 deletions rfqmsg/aux_features_dev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build dev

package rfqmsg

var (
// UseNoOpHTLCs is set to true, as we want to enable it for dev builds.
UseNoOpHTLCs = true
)
18 changes: 18 additions & 0 deletions rfqmsg/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/fn"
"github.com/lightninglabs/taproot-assets/rfqmath"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tlv"
)
Expand Down Expand Up @@ -59,6 +60,13 @@ type Htlc struct {

// RfqID is the RFQ ID that corresponds to the HTLC.
RfqID tlv.OptionalRecordT[HtlcRfqIDType, ID]

// NoopAdd is a flag that indicates whether this HTLC should be marked
// as a noop_add for LND. A noop_add HTLC behaves identically to a
// normal HTLC except for the settlement step, where the satoshi amount
// is returned back to the sender, but the commitment blob is still
// updated to reflect the asset balance changes.
NoopAdd bool
}

// NewHtlc creates a new Htlc record with the given funded assets.
Expand Down Expand Up @@ -135,9 +143,19 @@ func (h *Htlc) Records() []tlv.Record {
records = append(records, r.Record())
})

if h.NoopAdd {
r := tlv.NewPrimitiveRecord[lnwallet.NoopAddHtlcType](true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to update in the bLIPs.

records = append(records, r.Record())
}

return records
}

// SetNoopAdd flags the HTLC as a noop_add.
func (h *Htlc) SetNoopAdd(noopActive bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method, since we can just set the field directly, since it's exported?

h.NoopAdd = noopActive
}

// Encode serializes the Htlc to the given io.Writer.
func (h *Htlc) Encode(w io.Writer) error {
tlvRecords := h.Records()
Expand Down