mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
keysend: allow extratlvs parameter, even in non-experimental mode.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `keysend` now has `extratlvs` option in non-EXPERIMENTAL builds.
This commit is contained in:
parent
ce0f544073
commit
df4b477e88
3 changed files with 6 additions and 20 deletions
|
@ -4,7 +4,7 @@ lightning-keysend -- Send funds to a node without an invoice
|
|||
SYNOPSIS
|
||||
--------
|
||||
|
||||
**keysend** *destination* *msatoshi* [*label*] [*maxfeepercent*] [*retry\_for*] [*maxdelay*] [*exemptfee*]
|
||||
**keysend** *destination* *msatoshi* [*label*] [*maxfeepercent*] [*retry\_for*] [*maxdelay*] [*exemptfee*] [*extratlvs*]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
@ -36,6 +36,8 @@ Unlike lightning-pay(7), issuing the same `keysend` commands multiple times will
|
|||
Until *retry_for* seconds passes (default: 60), the command will keep finding routes and retrying the payment.
|
||||
However, a payment may be delayed for up to `maxdelay` blocks by another node; clients should be prepared for this worst case.
|
||||
|
||||
*extratlvs* is an optional dictionary of additional fields to insert into the final tlv. The format is 'fieldnumber': 'hexstring'.
|
||||
|
||||
When using *lightning-cli*, you may skip optional parameters by using
|
||||
*null*. Alternatively, use **-k** option to provide parameters by name.
|
||||
|
||||
|
|
|
@ -49,9 +49,7 @@ static struct keysend_data *keysend_init(struct payment *p)
|
|||
randombytes_buf(&d->preimage, sizeof(d->preimage));
|
||||
ccan_sha256(&payment_hash, &d->preimage, sizeof(d->preimage));
|
||||
p->payment_hash = tal_dup(p, struct sha256, &payment_hash);
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
d->extra_tlvs = NULL;
|
||||
#endif
|
||||
return d;
|
||||
} else {
|
||||
/* If we are a child payment (retry or split) we copy the
|
||||
|
@ -92,7 +90,6 @@ static void keysend_cb(struct keysend_data *d, struct payment *p) {
|
|||
tlvstream_set_raw(&last_payload->tlv_payload->fields, PREIMAGE_TLV_TYPE,
|
||||
&d->preimage, sizeof(struct preimage));
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
if (d->extra_tlvs != NULL) {
|
||||
for (size_t i = 0; i < tal_count(d->extra_tlvs); i++) {
|
||||
struct tlv_field *f = &d->extra_tlvs[i];
|
||||
|
@ -100,7 +97,6 @@ static void keysend_cb(struct keysend_data *d, struct payment *p) {
|
|||
f->numtype, f->value, f->length);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return payment_continue(p);
|
||||
}
|
||||
|
@ -148,9 +144,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
u32 *maxdelay;
|
||||
unsigned int *retryfor;
|
||||
struct route_info **hints;
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_field *extra_fields;
|
||||
#endif
|
||||
|
||||
#if DEVELOPER
|
||||
bool *use_shadow;
|
||||
|
@ -165,12 +159,10 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
p_opt_def("maxdelay", param_number, &maxdelay,
|
||||
maxdelay_default),
|
||||
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
||||
p_opt("extratlvs", param_extra_tlvs, &extra_fields),
|
||||
p_opt("routehints", param_routehint_array, &hints),
|
||||
#if DEVELOPER
|
||||
p_opt_def("use_shadow", param_bool, &use_shadow, true),
|
||||
#endif
|
||||
p_opt("routehints", param_routehint_array, &hints),
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
p_opt("extratlvs", param_extra_tlvs, &extra_fields),
|
||||
#endif
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
@ -210,10 +202,8 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
|
||||
p->constraints.cltv_budget = *maxdelay;
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
payment_mod_keysend_get_data(p)->extra_tlvs =
|
||||
tal_steal(p, extra_fields);
|
||||
#endif
|
||||
|
||||
payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
|
||||
#if DEVELOPER
|
||||
|
@ -365,14 +355,8 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
|
|||
return htlc_accepted_continue(cmd, NULL);
|
||||
}
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
/* Note: This is a magic pointer value, not an actual array */
|
||||
allowed = cast_const(u64 *, FROMWIRE_TLV_ANY_TYPE);
|
||||
#else
|
||||
/* We explicitly allow our type. */
|
||||
allowed = tal_arr(cmd, u64, 1);
|
||||
allowed[0] = PREIMAGE_TLV_TYPE;
|
||||
#endif
|
||||
|
||||
payload = tlv_tlv_payload_new(cmd);
|
||||
if (!fromwire_tlv(&rawpayload, &max, tlvs_tlv_tlv_payload, TLVS_ARRAY_SIZE_tlv_tlv_payload,
|
||||
|
|
|
@ -3568,7 +3568,7 @@ def test_keysend(node_factory):
|
|||
l3.rpc.keysend(l4.info['id'], amt)
|
||||
|
||||
|
||||
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "Requires extratlvs option")
|
||||
@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.
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue