paymod: Teach the adaptive splitter to respect the HTLC limit

There is little point in trying to split if the resulting HTLCs exceed the
maximum number of HTLCs we can add to our channels. So abort if a split would
result in more HTLCs than our channels can support.
This commit is contained in:
Christian Decker
2020-07-20 22:00:43 +02:00
committed by Rusty Russell
parent acdd9b8762
commit e92787a0e2
2 changed files with 51 additions and 11 deletions

View File

@@ -328,13 +328,15 @@ struct direct_pay_data {
struct short_channel_id_dir *chan;
};
/* Since presplit and adaptive mpp modifiers share the same information we
* just use the same backing struct. Should they deviate we can create an
* adaptive_splitter_mod_data struct and populate that. */
struct presplit_mod_data {
bool disable;
};
struct adaptive_split_mod_data {
bool disable;
u32 htlc_budget;
};
/* List of globally available payment modifiers. */
REGISTER_PAYMENT_MODIFIER_HEADER(retry, struct retry_mod_data);
REGISTER_PAYMENT_MODIFIER_HEADER(routehints, struct routehints_data);
@@ -343,7 +345,7 @@ REGISTER_PAYMENT_MODIFIER_HEADER(shadowroute, struct shadow_route_data);
REGISTER_PAYMENT_MODIFIER_HEADER(directpay, struct direct_pay_data);
extern struct payment_modifier waitblockheight_pay_mod;
REGISTER_PAYMENT_MODIFIER_HEADER(presplit, struct presplit_mod_data);
REGISTER_PAYMENT_MODIFIER_HEADER(adaptive_splitter, struct presplit_mod_data);
REGISTER_PAYMENT_MODIFIER_HEADER(adaptive_splitter, struct adaptive_split_mod_data);
/* For the root payment we can seed the channel_hints with the result from
* `listpeers`, hence avoid channels that we know have insufficient capacity