xpay: Allow "includefees" option to deduct fees from total.
This is actually really tricky to implement, but useful for the case of "I want to spend all my funds". Note that this is more specific than allowing "all" as them amount parameter to xpay:
- You may want to use it (with layers) to drain a specific channel.
- If you're using accounts (I'm writing such a plugin) "all my funds" may not be "all the funds on the node" but some subset.
It's particularly hard with bolt12, since you have to request the invoice with a specific amount (though, you can overpay!) and you don't know the route yet!
I don't think it is very difficult to implement in askrene.
The problems arise at the protocol level, I am guessing. Because the recipient doesn't know how much would he get. This means also trouble for MPP...
Unless the recipient himself computes the routes.
I think you end up approximating (assume max paid as fees), then increasing each payment slightly, then if all else fails, spending the last few sats on extra fees?