-
Notifications
You must be signed in to change notification settings - Fork 906
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
Onion TLV support (EXPERIMENTAL_FEATURE) #3167
Onion TLV support (EXPERIMENTAL_FEATURE) #3167
Conversation
tests/test_pay.py
Outdated
wait_for(lambda: 'alias' in l1.rpc.listnodes(l3.info['id'])['nodes'][0]) | ||
|
||
inv = l3.rpc.invoice(10000, "test_tlv3", "test_tlv3")['bolt11'] | ||
print(inv) |
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.
probably can delete this
40e81d9
to
82a38a1
Compare
Rebased on top of #3245 |
5bb917e
to
dcaf848
Compare
Back on top of master again... |
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.
Looking forward to seeing this merged :-)
vsize = bigsize_get(src, 3, &raw_size); | ||
hop_size = raw_size + vsize + HMAC_SIZE; | ||
step->type = SPHINX_TLV_PAYLOAD; | ||
} else { | ||
step->type = SPHINX_INVALID_PAYLOAD; | ||
return; |
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.
Good catch, the src[0] == 1
escape hatch got lost somewhere before.
/* This should probably be removed, as it's just for testing */ | ||
case SPHINX_RAW_PAYLOAD: | ||
abort(); | ||
} | ||
abort(); |
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.
Yes, if you want I can clean it up since it also touches the onion
-tool.
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.
The onion tool actually uses this to make an arbitrary raw payload, so we'll leave it for a bit longer.
@@ -81,6 +81,7 @@ struct route_step { | |||
enum sphinx_payload_type type; | |||
union { | |||
struct hop_data_legacy v0; | |||
struct tlv_tlv_payload *tlv; |
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.
Why not make this an instance of the struct tlv_tlv_payload
instead of a pointer to it? The struct itself only consists of 3 pointers (fixed size) and we'd be saving 1 allocation.
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.
Our marshaling/unmarshaling really wants a pointer...
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.
Hm, ok, I should read the TLV implementation more carefully :-)
devtools/onion.c
Outdated
/* FIXME: Generic realm support, not this hack! */ | ||
/* FIXME: Multi hop! */ | ||
/* /<hex> -> raw hopdata. /tlv -> TLV encoding. */ | ||
if (argv[1 + i][klen] != '\0' && argv[1 + i][klen] != 't') { |
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 seems to undo some of the fixes from #3250 (https://github.com/ElementsProject/lightning/pull/3250/files#diff-6ba0afe5becbb580348286dbd8ca2b5cR63). Which version is the correct one?
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.
I've just rebased again on master, which fixes this...
This highlights the various places we need to change. Signed-off-by: Rusty Russell <[email protected]>
We add routines to decode the expected fields from both legacy and tlv hop formats. Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]> Changelog-changed: JSON API: `htlc_accepted` hook has `type` (currently `legacy` or `tlv`) and other fields directly inside `onion`. Changelog-deprecated: JSON API: `htlc_accepted` hook `per_hop_v0` object deprecated, as is `short_channel_id` for the final hop.
We keep the feature bitmap on disk, so we cache this in the struct explicitly. Signed-off-by: Rusty Russell <[email protected]>
There's only one caller. Signed-off-by: Rusty Russell <[email protected]>
Default is legacy. If we have future styles, new strings can be defined, but for now it's "tlv" or "legacy". Signed-off-by: Rusty Russell <[email protected]>
For legacy, they were the same, but for TLV we care whether it's the final hop or not. Signed-off-by: Rusty Russell <[email protected]>
This means we can make sphinx_add_v0_hop static, too. Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
dcaf848
to
ed0b575
Compare
ACK ed0b575 |
No description provided.