-
Notifications
You must be signed in to change notification settings - Fork 123
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
rfqmsg: detect asset related custom records correctly #1322
Conversation
Pull Request Test Coverage Report for Build 12988277780Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉 Made some comments, no blockers.
rfqIDType HtlcRfqIDType | ||
) | ||
for key := range records { | ||
if key == uint64(amountType.TypeVal()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns true also if there's only one of the two custom records. Are there cases where we expect one but not the other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the asset keysend case I believe, there's no RFQ involved in that flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Technically an HTLC isn't valid if it has only the RFQ ID an no amount (but just amount and no RFQ ID is correct for the keysend case as George mentioned).
But that logic is out of scope for this function IMO, we just want to know if there are any asset related records present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice addition 🥕
LGTM
rfqIDType HtlcRfqIDType | ||
) | ||
for key := range records { | ||
if key == uint64(amountType.TypeVal()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the asset keysend case I believe, there's no RFQ involved in that flow
kicking the itests |
To save some space and not have a false positive on custom record detection, we only encode the HTLC asset amounts if the list is actually non-empty. This is mostly to get the unit test in the next commit to work and shouldn't have any direct real-world impact (as we should never encode the HTLC struct into an actual wire message if there aren't any values set inside the struct).
To detect whether an HTLC's custom records fields are values as we'd expect them to be set for an asset HTLC, we add a new helper function.
5317009
to
c97b302
Compare
To not interfere with other custom records, we only want to count an HTLC as an asset HTLC if it actually contains asset related custom records.
c97b302
to
d2271e0
Compare
Fixes #1321.