pay: fix handling of legacy vs tlv encoding.

As revealed by the failure of tests in #3936, where we ended up trying
to send a partial payment using legacy style, we are not handling
style properly.

1. BOLT9 has features, so we can *know* that the destination supports
   MPP.  We may not have seen a node_announcement.
2. We can't assume that nodes inside routehints support TLV.
3. We can't assume direct peers support TLV.

The keysend code tried to fix this up, so I'm not sure that this caused
the issue in #3968, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: `pay` will now make reliable multi-part payments to nodes it doesn't have a node_announcement for.
This commit is contained in:
Rusty Russell
2020-09-10 15:09:04 +09:30
parent 9587425f2d
commit 191355e0e7
4 changed files with 15 additions and 14 deletions

View File

@@ -52,18 +52,9 @@ static struct keysend_data *keysend_init(struct payment *p)
}
static void keysend_cb(struct keysend_data *d, struct payment *p) {
struct route_hop *last_hop;
struct createonion_hop *last_payload;
size_t hopcount;
if (p->step == PAYMENT_STEP_GOT_ROUTE) {
/* Force the last step to be a TLV, we might not have an
* announcement and it still supports it. Required later when
* we adjust the payload. */
last_hop = &p->route[tal_count(p->route) - 1];
last_hop->style = ROUTE_HOP_TLV;
}
if (p->step != PAYMENT_STEP_ONION_PAYLOAD)
return payment_continue(p);
@@ -143,6 +134,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
p->json_buffer = tal_steal(p, buf);
p->json_toks = params;
p->destination = tal_steal(p, destination);
p->destination_has_tlv = true;
p->payment_secret = NULL;
p->amount = *msat;
p->invoice = NULL;