keysend: Add routehints argument to the keysend command

So far we could not reach non-publicly reachable nodes with the
keysend command since we couldn't compute a route to them. With this
change we can add some routehints that we may have gotten from an
address book or a previous invoice, and make it more likely that we
can reach the destination.

Changelog-Added: keysend: `keysend` can now reach non-public nodes by providing the `routehints` argument if they are known.
This commit is contained in:
Christian Decker 2021-06-18 17:49:57 +02:00 committed by neil saitug
parent 415c2bfe3c
commit 94d11d1f9f

View File

@ -130,11 +130,12 @@ static const char *init(struct plugin *p, const char *buf UNUSED,
return NULL;
}
struct payment_modifier *pay_mods[8] = {
struct payment_modifier *pay_mods[] = {
&keysend_pay_mod,
&local_channel_hints_pay_mod,
&directpay_pay_mod,
&shadowroute_pay_mod,
&routehints_pay_mod,
&exemptfee_pay_mod,
&waitblockheight_pay_mod,
&retry_pay_mod,
@ -151,6 +152,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
u64 *maxfee_pct_millionths;
u32 *maxdelay;
unsigned int *retryfor;
struct route_info **hints;
#if EXPERIMENTAL_FEATURES
struct tlv_field *extra_fields;
#endif
@ -171,6 +173,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
#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
@ -185,7 +188,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
p->destination_has_tlv = true;
p->payment_secret = NULL;
p->amount = *msat;
p->routes = NULL;
p->routes = tal_steal(p, hints);
// 22 is the Rust-Lightning default and the highest minimum we know of.
p->min_final_cltv_expiry = 22;
p->features = NULL;