Skip to content

Feature: Just-in-time rebalance for pay #2683

Open
@ZmnSCPxj

Description

@ZmnSCPxj

If all our channels are too low to pay an invoice, but the sum of the spendable on those channels should be high enough, we should rebalance on the next pay attempt to consolidate our funds.

We need these:

  • Suggestion: lower-level "paycode" below "invoice" level #2666 Suggestion: lower-level "paycode" below "invoice" level - to not interfere with our own incoming invoices being watched by waitanyinvoice.
  • ensurepayable <channel> <amount_msat> <fee_budget_msat> -> success/fail - Ensure that the specific channel has a spendable amount greater or equal to amount_msat, spending at most fee_budget_msat to rebalance. This (and plugin: Implement the htlc_accepted hook #2267) can be used later by JIT-routing by @renepickhardt.
  • selectconnectedchannel [<min_capacity_msat>] [<node>] -> {'channel': <channel>}/fail - Select a well-connected local channel. If min_capacity_msat is specified, only select a channel whose capacity is at least the given capacity. If node is specified, prefer channels that are well-connected to this (possibly very remote) node. I think the "RouteBoost" code in invoice can work for the initial version of this; ignore node for now, but leave it as a future point for improvement later.
  • In the pay loop that creates the initial excludes, if all local channels get excluded, check if the total spendable is above the payment amount + fee budget. If so, selectconnectedchannel to the destination node and ensurepayable the returned channel, with a fraction of our own fee budget.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions