Skip to content

Commit bd0b79f

Browse files
committed
renepay: handle non-MPP invoices
Changelog-Fixed: renepay: Now able to handle invoices that don't support Multi-Path-Payments. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent 2facae2 commit bd0b79f

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

plugins/renepay/mods.c

+2
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ static struct command_result *getroutes_cb(struct payment *payment)
587587
json_add_string(req->js, NULL, "auto.sourcefree");
588588
json_add_string(req->js, NULL, payment->payment_layer);
589589
json_add_string(req->js, NULL, RENEPAY_LAYER);
590+
if (!payment->payment_info.use_mpp)
591+
json_add_string(req->js, NULL, "auto.no_mpp_support");
590592
json_array_end(req->js);
591593
// FIXME: add further constraints here if necessary when they become
592594
// available in getroutes

plugins/renepay/payment.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ bool payment_set_constraints(
108108
u64 min_prob_success_millionths,
109109
u64 base_prob_success_millionths,
110110
bool use_shadow,
111-
const struct route_exclusion **exclusions)
111+
const struct route_exclusion **exclusions,
112+
bool mpp_enabled)
112113
{
113114
// FIXME: add exclusions to a layer
114115
assert(p);
@@ -129,6 +130,7 @@ bool payment_set_constraints(
129130
pinfo->min_prob_success = min_prob_success_millionths / 1e6;
130131
pinfo->base_prob_success = base_prob_success_millionths / 1e6;
131132
pinfo->use_shadow = use_shadow;
133+
pinfo->use_mpp = mpp_enabled;
132134

133135
return true;
134136
}

plugins/renepay/payment.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ bool payment_set_constraints(
122122
u64 min_prob_success_millionths,
123123
u64 base_prob_success_millionths,
124124
bool use_shadow,
125-
const struct route_exclusion **exclusions);
125+
const struct route_exclusion **exclusions,
126+
bool mpp_enabled);
126127

127128
bool payment_refresh(struct payment *p);
128129

plugins/renepay/payment_info.h

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ struct payment_info {
8686

8787
/* --developer allows disabling shadow route */
8888
bool use_shadow;
89+
90+
/* Use Multi-Path-Payments feature. */
91+
bool use_mpp;
8992
};
9093

9194
#endif /* LIGHTNING_PLUGINS_RENEPAY_PAYMENT_INFO_H */

plugins/renepay/renepay.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
181181
const char *description;
182182
const char *label;
183183
struct route_exclusion **exclusions;
184+
bool mpp_enabled = true;
184185

185186
// dev options
186187
bool *use_shadow;
@@ -262,6 +263,8 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
262263
*inv_msat = amount_msat(*b12->invoice_amount);
263264
}
264265
payment_hash = b12->invoice_payment_hash;
266+
mpp_enabled =
267+
feature_offered(b12->invoice_features, OPT_BASIC_MPP);
265268
} else {
266269
b11 = bolt11_decode(tmpctx, invstr,
267270
plugin_feature_set(cmd->plugin),
@@ -280,6 +283,7 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
280283
inv_msat = b11->msat;
281284
invexpiry = b11->timestamp + b11->expiry;
282285
payment_hash = &b11->payment_hash;
286+
mpp_enabled = feature_offered(b11->features, OPT_BASIC_MPP);
283287
}
284288

285289
/* === Set default values for non-trivial constraints === */
@@ -396,7 +400,8 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
396400
*min_prob_success_millionths,
397401
*base_prob_success_millionths, use_shadow,
398402
cast_const2(const struct route_exclusion **,
399-
exclusions)) ||
403+
exclusions),
404+
mpp_enabled) ||
400405
!payment_refresh(payment))
401406
return command_fail(
402407
cmd, PLUGIN_ERROR,
@@ -431,7 +436,8 @@ static struct command_result *json_renepay(struct command *cmd, const char *buf,
431436
*min_prob_success_millionths,
432437
*base_prob_success_millionths, use_shadow,
433438
cast_const2(const struct route_exclusion **,
434-
exclusions)) ||
439+
exclusions),
440+
mpp_enabled) ||
435441
!payment_refresh(payment))
436442
return command_fail(
437443
cmd, PLUGIN_ERROR,

0 commit comments

Comments
 (0)