Skip to content
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

lnd keep transaction cancelled by RBF #5244

Open
nicolasburtey opened this issue Apr 27, 2021 · 13 comments
Open

lnd keep transaction cancelled by RBF #5244

nicolasburtey opened this issue Apr 27, 2021 · 13 comments
Assignees
Labels
rbf wallet The wallet (lnwallet) which LND uses

Comments

@nicolasburtey
Copy link

nicolasburtey commented Apr 27, 2021

Background

Send a tx to lnd from an outside wallet
Increase the fee on this same tx using RBF

lncli listunspent --unconfirmed_only shows both transaction instead of only the higher fees transaction.

( Note: doing a third tx with RBF will also keep the first two )

Your environment

  • version of lnd: 0.12.1-beta
  • which operating system (uname -a on *Nix): linux
  • version of btcd, bitcoind, or other backend: bitcoind
@nicolasburtey
Copy link
Author

may be a duplicate of #5225 ?

@wpaulino
Copy link
Contributor

Yeah it is a duplicate of #5225, just that in your case the RBF transactions were incoming rather than outgoing. The issue with this is that unconfirmed funds are not considered safe, especially when it comes to RBF. We can't always assume the latest replacement will make it into the chain over others (even when it has the highest fee of all replacements).

@Roasbeef
Copy link
Member

There's no guarantee that the latest one actually confirms, therefore the wallet always keeps around all variants.

@Roasbeef Roasbeef added rbf wallet The wallet (lnwallet) which LND uses labels Apr 29, 2021
@nicolasburtey
Copy link
Author

I think even after the transaction has been confirmed, lnd still keep the original as unconfirmed. AFAIR, the problem went away after a lnd reboot.

@wpaulino
Copy link
Contributor

I think even after the transaction has been confirmed, lnd still keep the original as unconfirmed. AFAIR, the problem went away after a lnd reboot.

@nicolasburtey I just tested this myself locally and wasn't able to reproduce: I sent coins to lnd from another wallet and RBF'd that transaction twice. I saw one output for each transaction before a block was mined. After a block was mined confirming the latest RBF attempt (the third transaction), lnd properly removed all other invalid outputs without a restart and only one confirmed UTXO exists. Is there a step that I'm missing?

@nicolasburtey
Copy link
Author

@nicolasburtey I just tested this myself locally and wasn't able to reproduce: I sent coins to lnd from another wallet and RBF'd that transaction twice. I saw one output for each transaction before a block was mined. After a block was mined confirming the latest RBF attempt (the third transaction), lnd properly removed all other invalid outputs without a restart and only one confirmed UTXO exists. Is there a step that I'm missing?

maybe you can remove this step

I sent coins to lnd from another wallet

by using a coin that doesn't come from lnd (or at least not pending from lnd, ie: has enough confirmation)

otherwise, not sure if this is relevant, but the issue was on mainnet, and the other wallet being used was specter.

@wpaulino
Copy link
Contributor

wpaulino commented Jun 2, 2021

by using a coin that doesn't come from lnd (or at least not pending from lnd, ie: has enough confirmation)
otherwise, not sure if this is relevant, but the issue was on mainnet, and the other wallet being used was specter.

@nicolasburtey I used Bitcoin Core's wallet on testnet to send to lnd and do the RBF bumps.

@nicolasburtey
Copy link
Author

so probably this bug is not deterministic?

maybe if this matters, the node having the issue have 1000+ onchain transactions.

@wpaulino
Copy link
Contributor

wpaulino commented Jun 3, 2021

@nicolasburtey I think if the replacement transactions ends up sending to a different address not related to lnd then this could also happen. Maybe this is what you experienced?

@nicolasburtey
Copy link
Author

I don't think this was the case for me. it was a RBF to the same address, basically bumping fees to make sure it get confirmed quickly.

@Roasbeef
Copy link
Member

So seems we tried to reproduce this in practice and we weren't able to? Just to clarify, until one of the transactions has fully confirmed you may see the dangling replacement transactions until one of them is properly confirmed. On top of that, when you "RBF", if you don't bump the fee of the transaction enough, it may not even propagate throughout the network, resulting in the last compliant bump being the one that ultimately confirms.

@qustavo
Copy link

qustavo commented Dec 22, 2021

I did reproduce this following @wpaulino's suggestion:

I think if the replacement transactions ends up sending to a different address not related to lnd then this could also happen.

My setup uses bitcoind-v22.0 and two lnd nodes (0.14 and 0.13)

I created and broadcasted an initial tx to send funds to the first node. listunspent lists the tx with 0 confirmations on the receiving node as expected.

Then I updated the previous tx's vout to point to the other node and the amount and broadcasted it. Now both nodes list the tx with 0 confirmations[1].

After mining 1 or more blocks, both nodes show the tx, the first node still displays 0 confirmation while the second updates the confirmations accordingly.

To create the first Tx I used:

bitcoin-cli createrawtransaction '[ {"txid": "$TX_ID", "vout":0, "sequence": 1} ]' '{"$DEST_ADDR_1": 49.9996}' 0 true
bitcoin-cli signrawtransactionwithwallet <output from the previous>
bitcoin-cli sendrawtransaction <output from the previous>

and to RBF (changes the address and amount):

bitcoin-cli createrawtransaction '[ {"txid": "$TX_ID", "vout":0, "sequence": 1} ]' '{"$DEST_ADDR_2": 49.9995}' 0 true
bitcoin-cli signrawtransactionwithwallet <output from the previous>
bitcoin-cli sendrawtransaction <output from the previous>

After mining a block, the first node should not list the tx since it has been RBF, instead it is stuck there.

1: At this point bitcoind's listunspent only shows one tx (the latest).

@arshbot
Copy link
Contributor

arshbot commented Jul 24, 2023

We're seeing this issue affect people at Voltage, particularly while developing Surge. Is it possible to have this endpoint return the value of the most recent RBF'd transaction (or the one with the highest fee)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rbf wallet The wallet (lnwallet) which LND uses
Projects
None yet
Development

No branches or pull requests

6 participants