Skip to content

Commit

Permalink
lightningd: allow extra tlv types in non-experimental mode.
Browse files Browse the repository at this point in the history
The old `experimental-accept-extra-tlv-types` is now `accept-htlc-tlv-types`.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Added: Config: `accept-htlc-tlv-types` lets us accept unknown even HTLC TLV fields we would normally reject on parsing (was EXPERIMENTAL-only `experimental-accept-extra-tlv-types`).
  • Loading branch information
rustyrussell committed Sep 21, 2022
1 parent fc016df commit f807ab6
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
5 changes: 3 additions & 2 deletions doc/lightning-listconfigs.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ On success, an object is returned, containing:
- **log-timestamps** (boolean, optional): `log-timestamps` field from config or cmdline, or default
- **force-feerates** (string, optional): force-feerate configuration setting, if any
- **subdaemon** (string, optional): `subdaemon` fields from config or cmdline if any (can be more than one)
- **fetchinvoice-noconnect** (boolean, optional): `featchinvoice-noconnect` fileds from config or cmdline, or default
- **fetchinvoice-noconnect** (boolean, optional): `fetchinvoice-noconnect` fields from config or cmdline, or default
- **accept-htlc-tlv-types** (string, optional): `accept-extra-tlvs-type` fields from config or cmdline, or not present
- **tor-service-password** (string, optional): `tor-service-password` field from config or cmdline, if any

[comment]: # (GENERATE-FROM-SCHEMA-END)
Expand Down Expand Up @@ -216,4 +217,4 @@ RESOURCES
---------

Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:dcab86f29b946fed925de5e05cb79faa03cc4421cefeab3561a596ed5e64962d)
[comment]: # ( SHA256STAMP:01b46b04f96e2139a5e247ae9e0bacde21ff574fd963b116553b80f4c5dc991f)
6 changes: 6 additions & 0 deletions doc/lightningd-config.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ the outgoing is redeemed.
might need to redeem this on-chain, so this is the number of blocks we
have to do that.

* **accept-htlc-tlv-types**=*types*

Normally HTLC onions which contain unknown even fields are rejected.
This option specifies that these (comma-separated) types are to be
accepted, and ignored.

### Invoice control options:

* **autocleaninvoice-cycle**=*SECONDS* [plugin `autoclean`]
Expand Down
6 changes: 5 additions & 1 deletion doc/schemas/listconfigs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,11 @@
},
"fetchinvoice-noconnect": {
"type": "boolean",
"description": "`featchinvoice-noconnect` fileds from config or cmdline, or default"
"description": "`fetchinvoice-noconnect` fields from config or cmdline, or default"
},
"accept-htlc-tlv-types": {
"type": "string",
"description": "`accept-extra-tlvs-type` fields from config or cmdline, or not present"
},
"tor-service-password": {
"type": "string",
Expand Down
3 changes: 1 addition & 2 deletions doc/undoc-flags.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"flags": [
"experimental-accept-extra-tlv-types",
"channel-fee-max-base-msat",
"channel-fee-max-proportional-thousandths",
"funder-fund-probability",
Expand All @@ -18,4 +17,4 @@
"lease-fee-basis",
"lease-funding-weight"
]
}
}
29 changes: 16 additions & 13 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,10 @@ static char *fmt_force_feerates(const tal_t *ctx, const u32 *force_feerates)
return ret;
}

#if EXPERIMENTAL_FEATURES
static char *opt_set_accept_extra_tlv_types(const char *arg,
struct lightningd *ld)
struct lightningd *ld)
{
char *endp, **elements = tal_strsplit(NULL, arg, ",", STR_NO_EMPTY);;
char *endp, **elements = tal_strsplit(NULL, arg, ",", STR_NO_EMPTY);
unsigned long long l;
u64 u;
for (int i = 0; elements[i] != NULL; i++) {
Expand All @@ -193,7 +192,6 @@ static char *opt_set_accept_extra_tlv_types(const char *arg,
tal_free(elements);
return NULL;
}
#endif

/* Returns the number of wireaddr types already announced */
static size_t num_announced_types(enum wire_addr_type type, struct lightningd *ld)
Expand Down Expand Up @@ -1174,11 +1172,9 @@ static void register_opts(struct lightningd *ld)
&ld->tor_service_password,
"Set a Tor hidden service password");

#if EXPERIMENTAL_FEATURES
opt_register_arg("--experimental-accept-extra-tlv-types",
opt_register_arg("--accept-htlc-tlv-types",
opt_set_accept_extra_tlv_types, NULL, ld,
"Comma separated list of extra TLV types to accept.");
#endif
"Comma separated list of extra HTLC TLV types to accept.");

opt_register_early_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns,
"Disable DNS lookups of peers");
Expand Down Expand Up @@ -1501,7 +1497,7 @@ static void add_config(struct lightningd *ld,
const char *name, size_t len)
{
char *name0 = tal_strndup(tmpctx, name, len);
const char *answer = NULL;
char *answer = NULL;
char buf[OPT_SHOW_LEN + sizeof("...")];

#if DEVELOPER
Expand Down Expand Up @@ -1597,7 +1593,7 @@ static void add_config(struct lightningd *ld,
if (ld->rgb)
answer = tal_hexstr(name0, ld->rgb, 3);
} else if (opt->cb_arg == (void *)opt_set_alias) {
answer = (const char *)ld->alias;
answer = (char *)ld->alias;
} else if (opt->cb_arg == (void *)arg_log_to_file) {
if (ld->logfiles)
json_add_opt_log_to_files(response, name0, ld->logfiles);
Expand Down Expand Up @@ -1660,10 +1656,17 @@ static void add_config(struct lightningd *ld,
fmt_amount_msat(tmpctx,
*(struct amount_msat *)
opt->u.carg));
#if EXPERIMENTAL_FEATURES
} else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) {
/* TODO Actually print the option */
#endif
for (size_t i = 0;
i < tal_count(ld->accept_extra_tlv_types);
i++) {
if (i == 0)
answer = tal_fmt(name0, "%"PRIu64,
ld->accept_extra_tlv_types[i]);
else
tal_append_fmt(&answer, ",%"PRIu64,
ld->accept_extra_tlv_types[i]);
}
#if DEVELOPER
} else if (strstarts(name, "dev-")) {
/* Ignore dev settings */
Expand Down
12 changes: 9 additions & 3 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3568,7 +3568,6 @@ def test_keysend(node_factory):
l3.rpc.keysend(l4.info['id'], amt)


@unittest.skipIf(not EXPERIMENTAL_FEATURES, "Requires experimental-accept-extra-tlv-types option")
def test_keysend_extra_tlvs(node_factory):
"""Use the extratlvs option to deliver a message with sphinx' TLV type.
"""
Expand All @@ -3577,14 +3576,21 @@ def test_keysend_extra_tlvs(node_factory):
2,
wait_for_announce=True,
opts=[
{},
{
'experimental-accept-extra-tlv-types': '133773310',
# Not needed, just for listconfigs test.
'accept-htlc-tlv-types': '133773310,99990',
},
{
'accept-htlc-tlv-types': '133773310',
"plugin": os.path.join(os.path.dirname(__file__), "plugins/sphinx-receiver.py"),
},
]
)

# Make sure listconfigs works here
assert l1.rpc.listconfigs()['accept-htlc-tlv-types'] == '133773310,99990'
assert l2.rpc.listconfigs()['accept-htlc-tlv-types'] == '133773310'

l1.rpc.keysend(l2.info['id'], amt, extratlvs={133773310: 'FEEDC0DE'})
inv = only_one(l2.rpc.listinvoices()['invoices'])
assert(l2.daemon.is_in_log(r'plugin-sphinx-receiver.py.*extratlvs.*133773310.*feedc0de'))
Expand Down

0 comments on commit f807ab6

Please sign in to comment.