-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build dev | ||
|
||
package rfqmsg | ||
|
||
// SetNoopAdd flags the HTLC as a noop_add. | ||
func (h *Htlc) SetNoopAdd() { | ||
h.NoopAdd = true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build !dev | ||
|
||
package rfqmsg | ||
|
||
// SetNoopAdd flags the HTLC as a noop_add. | ||
func (h *Htlc) SetNoopAdd() {} |
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,6 +143,11 @@ 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 | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,7 +431,14 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi, | |
if htlc.Amounts.Val.Sum() > 0 { | ||
log.Tracef("Already have asset amount (sum %d) in HTLC, not "+ | ||
"producing extra data", htlc.Amounts.Val.Sum()) | ||
return totalAmount, htlcCustomRecords, nil | ||
|
||
htlc.SetNoopAdd() | ||
updatedRecords, err := htlc.ToCustomRecords() | ||
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. Seems the aspect related to the reserve that you mentioned isn't in this PR yet? 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. It's not updated yet and it's on the LND PR, here we don't really have access to the channel state so we only decide whether we flag the noop to LND or not |
||
if err != nil { | ||
return 0, nil, err | ||
} | ||
|
||
return totalAmount, updatedRecords, nil | ||
} | ||
|
||
if htlc.RfqID.ValOpt().IsNone() { | ||
|
@@ -496,6 +503,12 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi, | |
// amount that should be sent on-chain, which is a value in satoshi that | ||
// is just above the dust limit. | ||
htlcAmountMSat := rfqmath.DefaultOnChainHtlcMSat | ||
|
||
// Now we set the flag that marks this HTLC as a noop_add, which means | ||
// that the above dust will eventually return to us. This means that | ||
// only the assets will be sent and not any btc balance. | ||
htlc.SetNoopAdd() | ||
|
||
updatedRecords, err := htlc.ToCustomRecords() | ||
if err != nil { | ||
return 0, nil, fmt.Errorf("error encoding HTLC blob: %w", err) | ||
|
Uh oh!
There was an error while loading. Please reload this page.