mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
lightningd: allow extra tlv types in non-experimental mode.
The old `experimental-accept-extra-tlv-types` is now `accept-htlc-tlv-types`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> 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`).
This commit is contained in:
@@ -97,7 +97,8 @@ On success, an object is returned, containing:
|
|||||||
- **log-timestamps** (boolean, optional): `log-timestamps` field from config or cmdline, or default
|
- **log-timestamps** (boolean, optional): `log-timestamps` field from config or cmdline, or default
|
||||||
- **force-feerates** (string, optional): force-feerate configuration setting, if any
|
- **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)
|
- **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
|
- **tor-service-password** (string, optional): `tor-service-password` field from config or cmdline, if any
|
||||||
- **dev-allowdustreserve** (boolean, optional): Whether we allow setting dust reserves
|
- **dev-allowdustreserve** (boolean, optional): Whether we allow setting dust reserves
|
||||||
|
|
||||||
@@ -217,5 +218,4 @@ RESOURCES
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
|
[comment]: # ( SHA256STAMP:5871ac751654339ed65ab905d61f0bc3afbb8576a33a5c4e9a73d2084f438582)
|
||||||
[comment]: # ( SHA256STAMP:310cc00ef62e7075d5d2588b0492c2dd96f507cc739f67d56ccc6c4f3135bca5)
|
|
||||||
|
|||||||
@@ -424,6 +424,12 @@ the outgoing is redeemed.
|
|||||||
might need to redeem this on-chain, so this is the number of blocks we
|
might need to redeem this on-chain, so this is the number of blocks we
|
||||||
have to do that.
|
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:
|
### Invoice control options:
|
||||||
|
|
||||||
* **autocleaninvoice-cycle**=*SECONDS* [plugin `autoclean`]
|
* **autocleaninvoice-cycle**=*SECONDS* [plugin `autoclean`]
|
||||||
|
|||||||
@@ -281,7 +281,11 @@
|
|||||||
},
|
},
|
||||||
"fetchinvoice-noconnect": {
|
"fetchinvoice-noconnect": {
|
||||||
"type": "boolean",
|
"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": {
|
"tor-service-password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"flags": [
|
"flags": [
|
||||||
"experimental-accept-extra-tlv-types",
|
|
||||||
"channel-fee-max-base-msat",
|
"channel-fee-max-base-msat",
|
||||||
"channel-fee-max-proportional-thousandths",
|
"channel-fee-max-proportional-thousandths",
|
||||||
"funder-fund-probability",
|
"funder-fund-probability",
|
||||||
|
|||||||
@@ -171,11 +171,10 @@ static char *fmt_force_feerates(const tal_t *ctx, const u32 *force_feerates)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EXPERIMENTAL_FEATURES
|
|
||||||
static char *opt_set_accept_extra_tlv_types(const char *arg,
|
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;
|
unsigned long long l;
|
||||||
u64 u;
|
u64 u;
|
||||||
for (int i = 0; elements[i] != NULL; i++) {
|
for (int i = 0; elements[i] != NULL; i++) {
|
||||||
@@ -193,7 +192,6 @@ static char *opt_set_accept_extra_tlv_types(const char *arg,
|
|||||||
tal_free(elements);
|
tal_free(elements);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Returns the number of wireaddr types already announced */
|
/* Returns the number of wireaddr types already announced */
|
||||||
static size_t num_announced_types(enum wire_addr_type type, struct lightningd *ld)
|
static size_t num_announced_types(enum wire_addr_type type, struct lightningd *ld)
|
||||||
@@ -1182,11 +1180,9 @@ static void register_opts(struct lightningd *ld)
|
|||||||
&ld->tor_service_password,
|
&ld->tor_service_password,
|
||||||
"Set a Tor hidden service password");
|
"Set a Tor hidden service password");
|
||||||
|
|
||||||
#if EXPERIMENTAL_FEATURES
|
opt_register_arg("--accept-htlc-tlv-types",
|
||||||
opt_register_arg("--experimental-accept-extra-tlv-types",
|
|
||||||
opt_set_accept_extra_tlv_types, NULL, ld,
|
opt_set_accept_extra_tlv_types, NULL, ld,
|
||||||
"Comma separated list of extra TLV types to accept.");
|
"Comma separated list of extra HTLC TLV types to accept.");
|
||||||
#endif
|
|
||||||
|
|
||||||
opt_register_early_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns,
|
opt_register_early_noarg("--disable-dns", opt_set_invbool, &ld->config.use_dns,
|
||||||
"Disable DNS lookups of peers");
|
"Disable DNS lookups of peers");
|
||||||
@@ -1509,7 +1505,7 @@ static void add_config(struct lightningd *ld,
|
|||||||
const char *name, size_t len)
|
const char *name, size_t len)
|
||||||
{
|
{
|
||||||
char *name0 = tal_strndup(tmpctx, name, len);
|
char *name0 = tal_strndup(tmpctx, name, len);
|
||||||
const char *answer = NULL;
|
char *answer = NULL;
|
||||||
char buf[OPT_SHOW_LEN + sizeof("...")];
|
char buf[OPT_SHOW_LEN + sizeof("...")];
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
@@ -1605,7 +1601,7 @@ static void add_config(struct lightningd *ld,
|
|||||||
if (ld->rgb)
|
if (ld->rgb)
|
||||||
answer = tal_hexstr(name0, ld->rgb, 3);
|
answer = tal_hexstr(name0, ld->rgb, 3);
|
||||||
} else if (opt->cb_arg == (void *)opt_set_alias) {
|
} 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) {
|
} else if (opt->cb_arg == (void *)arg_log_to_file) {
|
||||||
if (ld->logfiles)
|
if (ld->logfiles)
|
||||||
json_add_opt_log_to_files(response, name0, ld->logfiles);
|
json_add_opt_log_to_files(response, name0, ld->logfiles);
|
||||||
@@ -1668,10 +1664,17 @@ static void add_config(struct lightningd *ld,
|
|||||||
fmt_amount_msat(tmpctx,
|
fmt_amount_msat(tmpctx,
|
||||||
*(struct amount_msat *)
|
*(struct amount_msat *)
|
||||||
opt->u.carg));
|
opt->u.carg));
|
||||||
#if EXPERIMENTAL_FEATURES
|
|
||||||
} else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) {
|
} else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) {
|
||||||
/* TODO Actually print the option */
|
for (size_t i = 0;
|
||||||
#endif
|
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
|
#if DEVELOPER
|
||||||
} else if (strstarts(name, "dev-")) {
|
} else if (strstarts(name, "dev-")) {
|
||||||
/* Ignore dev settings */
|
/* Ignore dev settings */
|
||||||
|
|||||||
@@ -3568,7 +3568,6 @@ def test_keysend(node_factory):
|
|||||||
l3.rpc.keysend(l4.info['id'], amt)
|
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):
|
def test_keysend_extra_tlvs(node_factory):
|
||||||
"""Use the extratlvs option to deliver a message with sphinx' TLV type.
|
"""Use the extratlvs option to deliver a message with sphinx' TLV type.
|
||||||
"""
|
"""
|
||||||
@@ -3577,14 +3576,21 @@ def test_keysend_extra_tlvs(node_factory):
|
|||||||
2,
|
2,
|
||||||
wait_for_announce=True,
|
wait_for_announce=True,
|
||||||
opts=[
|
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"),
|
"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'})
|
l1.rpc.keysend(l2.info['id'], amt, extratlvs={133773310: 'FEEDC0DE'})
|
||||||
inv = only_one(l2.rpc.listinvoices()['invoices'])
|
inv = only_one(l2.rpc.listinvoices()['invoices'])
|
||||||
assert(l2.daemon.is_in_log(r'plugin-sphinx-receiver.py.*extratlvs.*133773310.*feedc0de'))
|
assert(l2.daemon.is_in_log(r'plugin-sphinx-receiver.py.*extratlvs.*133773310.*feedc0de'))
|
||||||
|
|||||||
Reference in New Issue
Block a user