lightningdevkit / rust-lightning

A highly modular Bitcoin Lightning library written in Rust. It's rust-lightning, not Rusty's Lightning!
Other
1.14k stars 363 forks source link

BOLT12 sending doesn't allow to override `{Route,Payment}Parameters` #3262

Open tnull opened 1 month ago

tnull commented 1 month ago

For BOLT11 we allow to set RouteParameters as an argument to send_payment. However, pay_for_offer only allows to set max_total_routing_fee_msat, but not other routing-related fields such as max_total_cltv_expiry_delta, max_path_count, max_channel_saturation_power_of_half.

I'm a bit dubious if pay_for_offer and paying for refunds should be parametrized by RouteParameters, PaymentParameters, or the relevant fields independently, but we should provide a way to set them for BOLT12 payments, too.

TheBlueMatt commented 2 weeks ago

Right, so the {Route,Payment}Parameters abstractions don't make any sense in a BOLT 12 world. They also don't really make sense in a BOLT 11 world if we pass a Bolt11Invoice directly to ChannelManager (which we should do now that lightning depends on lightning-invoice).

So I think this tees us up for a nice patchset - define some new struct which captures the options you describe, pass it to pay_for_offer and use that + the BOLT 12 invoice to build an initial RouteParameters, then do the same on the BOLT 11 side - drop lightning::ln::bolt11_payment and replace it with a Channelmanager method that does the same thing as the BOLT 12 path, just with BOLT 11 and the new parameters struct.

shaavan commented 3 days ago

Giving this a shot! 🚀