-
Notifications
You must be signed in to change notification settings - Fork 276
Support additional TLV records in SendPayentRequest #1367
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
Conversation
t-bast
left a comment
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.
Great, this doesn't require much code to integrate.
I'd also add a test (if there isn't already one) to verify that the encoding of those user-enriched onions works properly.
eclair-core/src/main/scala/fr/acinq/eclair/payment/send/PaymentInitiator.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/send/PaymentInitiator.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1367 +/- ##
==========================================
+ Coverage 86.30% 86.60% +0.29%
==========================================
Files 119 119
Lines 9306 9478 +172
Branches 387 397 +10
==========================================
+ Hits 8032 8208 +176
+ Misses 1274 1270 -4
|
|
I've added an extra test for the encoding/decoding of a TLV based FinalPayload with some custom records. There is another incompatibility that i found when developing |
eclair-core/src/main/scala/fr/acinq/eclair/payment/send/PaymentInitiator.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/send/PaymentInitiator.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/OnionCodecsSpec.scala
Outdated
Show resolved
Hide resolved
I think it makes sense to have the keysend record be even. If you include it, you really need the receiver to understand it (otherwise your payment won't work). Are you saying that eclair fails to include this record because we don't allow writing an unknown even type? Or are you saying that eclair will not allow receiving that keysend record (which is the right behavior)? |
|
I'm still having some troubles while choosing the right format for the final payload, with the current logic we generate the TLV payload if there is a payment secret or there are user defined TLV records, however when paying an invoice with optional MPP (but we have MPP disabled) we should still generate a legacy payload but this is not the case because the invoice contains the payment secret (see test). If we match only on the user defined TLV records and append the optional payment secret as TLV record we break the node relayer. |
Yes eclair fails to produce the record because we don't allow writing an unknown even type, is this behavior correct? (I imagined we only want that when reading to make sure we understand the payment data) |
Ok that's what I feared, I think for |
So it's okay to allow unknown records to have an even type? If yes then something like this should do the trick |
|
Here is my proposal: 4c26529 I changed the codecs to allow encoding unknown even tlvs, but still reject decoding such types. That means user will be able to use eclair to send payments to endpoints that support |
ACK,i was just merging your proposed change with mines. I think it would be nice if we allow decoding unkown even types in the high range (especially for keysend) and the spec is not very clear here, in fact there is one interpretation by which the |
d4ebe44 to
e0fff32
Compare
…gle-part and MPP)
e0fff32 to
e98af20
Compare
t-bast
left a comment
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.
e98af20 is a good first step!
As discussed offline, the next commits should:
- add a whitelist of unknown tlv records to the config
- allow plugins register unknown tlv records that they handle
- pass that whitelist to the TLV codecs so that they allow encoding/decoding these white-listed records
Note that I think that once we have this whitelist, we should use it for both encoding and decoding.
The current code allows encoding any unknown even tlv record, but if we do implement a whitelist mechanism we should revert that and only allow encoding the white-listed tlv records.
|
Latest commit allows to encode unknown even types but not to decode them. I gave a few shots to allow plugins to export a list of whitelisted even TLV types in 217862b although i'm not very satisfied with it. We can have a new plugin hook that is used in Boot/Setup to inject a list of Some possible alternatives:
|
eclair-core/src/test/scala/fr/acinq/eclair/payment/PaymentInitiatorSpec.scala
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/wire/TlvCodecs.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/TlvCodecsSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/wire/TlvCodecsSpec.scala
Outdated
Show resolved
Hide resolved
t-bast
left a comment
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!
This PR adds the possibility to attach extra TLV records when sending a payment, the feature is meant to be used by plugin developers and experimentally via API (although this PR is missing the API part). It will allow to support features like
keysend(invoiceless payments) and/or custom messages attached as TLV record to final onion packet.I've chosen to not support this feature in trampoline/mpp payments for the moment because i'm not aware of any custom protocol built on top them.
Users willing to experiment with this feature must take care of properly sorting the extra TLV records.