Consider setting RBF flag for Lightning funding transactions
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- blockchain, payments
Research direction
Read the RBF and fee-bumping logic in electrum/lnpeer.py and electrum/wallet.py, including the linked lines. Compare the funding-transaction, bump_fee, and dscancel behavior with the multi-device and channel-recovery concerns described here. Done requires a decided, safe policy for RBF and fee actions, but this issue does not specify an implementation or tests.
Written by the indexing model from the issue text.
Description
Currently we intentionally don't set the RBF flag for LN funding transactions (channel opening txs).
https://github.com/spesmilo/electrum/blob/84326cf1f78f60201e5bac44ff306c240147adde/electrum/lnpeer.py#L686
This means that if the user lowballs the fee, the funding tx can get stuck in the mempool in limbo for a very long time, and the user has essentially no recourse: all they can do is wait.
To be clear, with current the Lightning/BOLT v1 spec, it is not possible to non-destructively bump the fee of a funding transaction. That is, if we bump the fee and keep the funding output, the txid changes which invalidates the channel id, and the remote peer will not find the funding outpoint -- the funds then can only be recovered manually through with the help of the channel counterparty.
Bumping the fee should be possible in the future with the channel v2 spec (https://github.com/lightningnetwork/lightning-rfc/pull/524), but naturally only in a collaborative way (the peers need to exchange messages).
Code in wallet.py only allows bumping the fee of a tx that both (1) opted in to RBF, and (2) is not a LN funding tx for one of our channels:
https://github.com/spesmilo/electrum/blob/84326cf1f78f60201e5bac44ff306c240147adde/electrum/wallet.py#L618
https://github.com/spesmilo/electrum/blob/84326cf1f78f60201e5bac44ff306c240147adde/electrum/wallet.py#L647-L648
As said at the beginning, we don't set RBF for our funding txs, so check (2) is actually not relied on right now.
The issue is that not opting in to RBF not only disables bump_fee but also e.g. double-spend cancelling the tx:
https://github.com/spesmilo/electrum/blob/84326cf1f78f60201e5bac44ff306c240147adde/electrum/wallet.py#L619
(and not just in the code but on a bitcoin p2p relay level as well).
So, we could opt-in to RBF, detect the tx is a funding tx, and not allow bump_fee but still allow dscancel.
Further, advanced users can always manually craft conflicting txs that spend the coins in a custom manner, but relaying the tx on bitcoin peer-to-peer is kind of hopeless without opt-in RBF.
However, what if the user uses the same wallet (seed) on multiple devices?! Check (2) only works on the device that has the Lightning state for said channel. If we opt-in to RBF, the user might shoot themselves in the foot and run bump_fee on the funding tx on another device.
Note that even with channel v2, this core problem remains: and it actually becomes more likely I expect! LN peers likely will want to opt-in to RBF, and users with multiple devices might run bump_fee on the funding tx - and the second device does not know to notify the channel counterparty about the replacement.
Note that we have been thinking about putting an OP_RETURN output on funding txs, with some encrypted data, for channel-recovery purposes. That would also mitigate this, if the second device is able to decrypt the data and identify the tx as a funding tx (and disable bump_fee in that case in the UI).
- Dominant language
- Python
- Stars
- 8.6k
- Forks
- 3.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 61
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spesmilo/electrum
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
build/packaging 📦 OS-linux 🐧
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
OS-android🤖
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
All issues in spesmilo/electrum
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100