-
Notifications
You must be signed in to change notification settings - Fork 132
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
GeorgeTsagk
wants to merge
4
commits into
main
Choose a base branch
from
noop-add-tlv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
) | ||
|
@@ -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. | ||
|
@@ -135,9 +143,19 @@ func (h *Htlc) Records() []tlv.Record { | |
records = append(records, r.Record()) | ||
}) | ||
|
||
if h.NoopAdd { | ||
r := tlv.NewPrimitiveRecord[lnwallet.NoopAddHtlcType](true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.