Browse Source

mpp: Detect if destination supports MPP from invoice and abort early

We abort on the root since that is the coordination point for all parts of the payment.
release-0.9.0
Christian Decker 5 years ago
parent
commit
718b6e3398
  1. 17
      plugins/libplugin-pay.c

17
plugins/libplugin-pay.c

@ -39,6 +39,8 @@ struct payment *payment_new(tal_t *ctx, struct command *cmd,
/* Re-establish the unmodified constraints for our sub-payment. */
p->constraints = *parent->start_constraints;
p->deadline = parent->deadline;
p->invoice = parent->invoice;
} else {
assert(cmd != NULL);
p->partid = 0;
@ -715,6 +717,7 @@ payment_waitsendpay_finished(struct command *cmd, const char *buffer,
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
p->result->code = PAY_DESTINATION_PERM_FAIL;
root->abort = true;
case WIRE_MPP_TIMEOUT:
/* These are permanent failures that should abort all of our
* attempts right away. We'll still track pending partial
@ -2094,6 +2097,14 @@ static struct presplit_mod_data *presplit_mod_data_init(struct payment *p)
}
}
static bool payment_supports_mpp(struct payment *p)
{
if (p->invoice == NULL || p->invoice->features == NULL)
return false;
return feature_offered(p->invoice->features, OPT_BASIC_MPP);
}
static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
{
struct payment *root = payment_root(p);
@ -2102,6 +2113,9 @@ static void presplit_cb(struct presplit_mod_data *d, struct payment *p)
if (d->disable)
return payment_continue(p);
if (!payment_supports_mpp(p))
return payment_continue(p);
if (p->step == PAYMENT_STEP_ONION_PAYLOAD) {
/* We need to tell the last hop the total we're going to
* send. Presplit disables amount fuzzing, so we should always
@ -2214,6 +2228,9 @@ static void adaptive_splitter_cb(struct presplit_mod_data *d, struct payment *p)
if (d->disable)
return payment_continue(p);
if (!payment_supports_mpp(p) || root->abort)
return payment_continue(p);
if (p->step == PAYMENT_STEP_ONION_PAYLOAD) {
/* We need to tell the last hop the total we're going to
* send. Presplit disables amount fuzzing, so we should always

Loading…
Cancel
Save