-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With an anchor-channel open having only a single UTXO cannot be selected for SendCoins
/SendMany
#5648
Comments
SendCoins
SendCoins
/SendMany
An attempt to verify this is here: https://github.com/lightningnetwork/lnd/blob/master/lnwallet/wallet.go#L1004 So you have a reproducible scenario where you aren't trying to send the entire balance of the wallet out that triggers this assertion? |
Exactly, I am only trying to send an amount that would leave (more than) enough for the reserved value in the wallet. Just from a real quick debugging of the check that you link to I can see that both the external address but also the "automatically" created change address are NOT considered as belonging to the wallet in that check. |
One way to start to pinpoint this would be to write a new unit tests in the wallet that creates an address and ensure that the |
It seems the problem is that when Lines 983 to 995 in 4487acc
Since the transaction was made in dry-run mode it did not commit anything to the db, hence also not that it created a new change address, which is therefore not picked up from the check. The actual logic for the dry-run happens inside the As expected when calling A better approach may be to actually make use of the |
You mean manually create that change address before we call |
Is there a method that allows deriving the next internal/change key, without advancing the counter? Because I couldn't find one. My question was more if it would be acceptable to make use of the I have opened a PR with a minimal change that makes use of it, as it is probably easier to reason about this in code :) |
Yes: https://github.com/lightningnetwork/lnd/blob/master/keychain/derivation.go#L163 |
Could this be related to #5539? |
@Kixunil If I understand #5539 correctly, then the wallet reserve invalidated error is happening immediately when wanting to open a channel interactively utilizing PSBT (with e.g. an empty internal wallet), before actually providing the change/funding output for the reserved wallet balance yet? In that case I don't think it is directly related, as this issue is at a later stage where actually all information on change outputs would be available. |
Facing this same issue with a new signet v0.13.1 node with one UTXO and one anchor channel. Couldn't send any amount to my electrum wallet. Had to send to own address, and then to electrum. |
I can reproduce this issue as well. On a regtest node I have 3 utxos totaling 6 btc, I cannot start a psbt funded channel open with all 3 utxos even though the channel size is only 100k sats. |
Background
When using anchor-channels a minimum reserved wallet balance is required (10_000 sats/channel; maximum 100_000 sats).
When the node has some anchor-channel open and only a single UTXO in the wallet, then calling
SendCoins
orSendMany
to send some on-chain funds out is impossible as it returns the errorreserved wallet balance invalidated
, even though we send out an amount that would leave sufficient funds on the node.However, it is still possible to call
OpenChannel
to open a channel as long as we fund it with an amount that leaves enough on-chain funds for the reserved wallet balance.As a work-around it is possible to request a new address on the node and then use
SendCoins
orSendMany
to actively send an amount equal to (or greater than) the required reserved wallet balance to your own address. This splits the UTXO and makes it possible to now send funds out again.It therefore seems that the problem is that the check for reserved wallet balance is done without knowledge of a change output using
SendCoins
/SendMany
, while this is known when opening a new channel withOpenChannel
?Your environment
lnd
: 0.13.0/0.13.1uname -a
on *Nix): linuxSteps to reproduce
SendCoins
/SendMany
when trying to send to an external address (even though the transaction would leave sufficient funds for the wallet reserve on the node).newaddress
.Expected behaviour
It should be possible to detect that the change output of a transaction from
SendCoins
/SendMany
would leave sufficient wallet reserve funds.Actual behaviour
The error
reserved wallet balance invalidated
is returned.The text was updated successfully, but these errors were encountered: