lnd icon indicating copy to clipboard operation
lnd copied to clipboard

[Request] sendcoins all / openchannel all

Open junderw opened this issue 7 years ago • 14 comments
trafficstars

Reason: Currently, if I want to spend 100% of my funds onchain OR spend 100% of my funds to a channel, I need to dance back and forth by overshooting it and seeing the error message telling me how much I need, subtract, then send the exact amount.

Flow

  • User specifies in the args that "I want to send as much as possible accounting for fees" ( ALL in place of the local_amt etc.)
  • lnd calculates the fees for the opening channel transaction normally, and subtracts that from available witness outputs (for openchannel) or all inputs (for sendcoins) and performs the send operation without interaction from the user.

junderw avatar Jan 18 '18 01:01 junderw

I will give it crack!

t4sk avatar Mar 03 '18 03:03 t4sk

@t4sk are you actively working on this?

githubsands avatar Mar 08 '18 22:03 githubsands

@githubsands I am planning to work on it this weekend but I am also happy to hand it over to you :)

t4sk avatar Mar 09 '18 00:03 t4sk

AFAIK, this issue is still up for grabs!

Roasbeef avatar Jun 16 '18 02:06 Roasbeef

This would actually be super useful. I might pick it up if nobody else has raised a PR.

simonhorlick avatar Jun 16 '18 09:06 simonhorlick

For the openchannel case I feel like the main issue here is that the user has to guess the fee. For example the following flow is frustrating:

$ lncli walletbalance
{
    "total_balance": "16768865",
    "confirmed_balance": "16768865",
    "unconfirmed_balance": "0"
}
$ lncli openchannel 03dfb7ad0bda82ecb7b516a57c914bbcb71a58cf4f70d22d313731b33a9a7de3d0 16768865
[lncli] rpc error: code = Unknown desc = not enough witness outputs to create funding transaction, need 0.16776515 BTC only have 0.16768865 BTC  available

We could take the fee from local_amt by default, but the change of behaviour might surprise users. We could also add a new option such as --include-fee that makes it explicit that the local_amt includes the fee.

Finally, do we want to commit 100% to channel balances, or should we reserve a certain amount in case fees increase later on? From BOLT2:

Given the variance in fees, and the fact that the transaction may be spent in the future, it's a good idea for the fee payer to keep a good margin (say 5x the expected fee requirement); but, due to differing methods of fee estimation, an exact value is not specified.

simonhorlick avatar Jun 17 '18 03:06 simonhorlick

a new option such as --include-fee

This should be sufficient.

do we want to commit 100% to channel balances

This could also be another arg.

So in summary:

  1. Add --include-fee arg to openchannel and sencoins.
  2. Add --ignore-fee-buffer for openchannel (assuming lnd is already calculating some buffer for fees that it is not allowing to be used for openchannel) to ignore the buffer and allow sending all funds to an openchannel.

dabura667 avatar Jun 17 '18 07:06 dabura667

I was confusing the fee for the funding tx and the commitment tx. In this issue I only really care about the funding tx.

simonhorlick avatar Jun 18 '18 02:06 simonhorlick

This feature is really needed, any progress?

Talkless avatar Dec 08 '18 10:12 Talkless

See #2198

Roasbeef avatar Dec 09 '18 23:12 Roasbeef

The ability to send all the coins out of the wallet has been merged. The follow up would be a similar command to take all those UTXOs and fund a channel.

Roasbeef avatar Jan 15 '19 22:01 Roasbeef

I will take a look and try to implement the functionality of this for opening channels.

bjarnemagnussen avatar Feb 21 '20 03:02 bjarnemagnussen

Will be fixed by #4029.

guggero avatar Sep 08 '20 18:09 guggero

Will be fixed by https://github.com/lightningnetwork/lnd/pull/6903 owned by @hieblmi

saubyk avatar Sep 14 '22 03:09 saubyk