Skip to content

feature request: add button to balance all existing channels in current network #831

@uwla

Description

@uwla

Is your feature request related to a problem? Please describe.
Yes, the problem is: sometimes we need balanced channels to do some stuff while testing and developing locally, but balancing them manually takes precious time.

Describe the solution you'd like
A button that we can click and have the channels balanced automatically (in the background by polar).

Suggestion

Here is a pseudo-code to balance the channels:

button.onClick((event) => {
  for (channel of getChannels()) {
    amountPeer1 = channel.getAmountPeer1()
    amountPeer2 = channel.getAmountPeer2()
    if (amountPeer1 == amountPeer2)
      continue;
    if (amountPeer 1 > amountPeer2) {
      invoice = channel.generateInvoiceForPeer2({ amount: (amountPeer1-amountPeer)/2 })
      channel.payInvoiceToPeer2(invoice)
    } else {
      // same thing as above
    }
  }
})

I can try do this, but some guidance is welcomed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions