Skip to content

Use bitcoin core's txospenderindex to find spending transactions - #3279

Draft
sstone wants to merge 2 commits into
masterfrom
use-txospenderindex
Draft

Use bitcoin core's txospenderindex to find spending transactions#3279
sstone wants to merge 2 commits into
masterfrom
use-txospenderindex

Conversation

@sstone

@sstone sstone commented Apr 2, 2026

Copy link
Copy Markdown
Member

Eclair now requires that bitcoin core's txospenderindex (added in version 31.0) is available and synced, and will fail to start if it is not.

Our Watcher will use the txospenderindex` to find spending transactions instead of scanning blocks (which was both expensive and limited as we would only scan a small number of blocks into the past).

Deployment note:

You must enable the new index on bitcoin core with txospenderindex=1 and wait until it is synchronised before you start eclair. Syncing the index from scratch will take a few hours, during which bitcoin core is usable (indexes are independent) but make be slower to respond.
You can also copy the index from another node (that is running the same version), just copy the entire .bitcoin/indexes/txospenderindex directory.

The index requires an additional 88Gb as of block 944339.

@sstone sstone changed the title Use bitcoin core's txospenderindex find spending transaction Use bitcoin core's txospenderindex to find spending transaction Apr 2, 2026
@sstone sstone changed the title Use bitcoin core's txospenderindex to find spending transaction Use bitcoin core's txospenderindex to find spending transactions Apr 2, 2026
@sstone
sstone force-pushed the use-txospenderindex branch 4 times, most recently from 513211e to d3d7f3c Compare April 22, 2026 14:33
@sstone
sstone force-pushed the use-txospenderindex branch 3 times, most recently from 00d357b to 7b7eb49 Compare April 30, 2026 11:23
@sstone
sstone force-pushed the use-txospenderindex branch from 7b7eb49 to cd31b14 Compare May 7, 2026 12:01
@pm47

pm47 commented May 7, 2026

Copy link
Copy Markdown
Member

As discussed offline, imo we should make txospenderindex a hard requirement (just like txindex) and drop the block scanning implementation altogether. This was just really a hacky workaround. Simplification FTW!

@sstone

sstone commented May 7, 2026

Copy link
Copy Markdown
Member Author

As discussed offline, imo we should make txospenderindex a hard requirement (just like txindex) and drop the block scanning implementation altogether. This was just really a hacky workaround. Simplification FTW!

done in cd31b14. Eclair won't start if the index is not enabled and synced.

@sstone
sstone force-pushed the use-txospenderindex branch from cd31b14 to de16a8a Compare May 21, 2026 14:02
@sstone
sstone force-pushed the use-txospenderindex branch from de16a8a to c350f3b Compare June 15, 2026 08:40
@sstone
sstone force-pushed the use-txospenderindex branch 4 times, most recently from ae37aec to af477fd Compare July 9, 2026 15:31
t-bast added a commit that referenced this pull request Jul 17, 2026
This release contains a new index which we need for #3279.
@sstone
sstone force-pushed the use-txospenderindex branch from af477fd to e045d0b Compare July 30, 2026 08:42
@sstone
sstone force-pushed the use-txospenderindex branch from e045d0b to fe4b460 Compare August 13, 2026 12:35
@t-bast

t-bast commented Aug 21, 2026

Copy link
Copy Markdown
Member

We should make sure that we only merge this PR once we're using a version of bitcoind that includes bitcoin/bitcoin#35531, since it vastly improves the index.

@fanquake

fanquake commented Aug 21, 2026

Copy link
Copy Markdown

a version of bitcoind that includes bitcoin/bitcoin#35531

The first release that will contain that change will be 32.0 (bitcoin/bitcoin#35122).

@t-bast

t-bast commented Aug 21, 2026

Copy link
Copy Markdown
Member

Thanks @fanquake 🙏

@hodlinator

Copy link
Copy Markdown

32.0 will also contain this fix: bitcoin/bitcoin#35889

@sstone
sstone force-pushed the use-txospenderindex branch from fe4b460 to 19e21c3 Compare August 25, 2026 07:26
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.64%. Comparing base (d769db0) to head (19e21c3).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
.../acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala 80.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3279      +/-   ##
==========================================
- Coverage   88.64%   88.64%   -0.01%     
==========================================
  Files         222      223       +1     
  Lines       21910    22107     +197     
  Branches      867      889      +22     
==========================================
+ Hits        19423    19597     +174     
- Misses       2487     2510      +23     
Files with missing lines Coverage Δ
...ir-core/src/main/scala/fr/acinq/eclair/Setup.scala 72.10% <100.00%> (+0.75%) ⬆️
...ala/fr/acinq/eclair/blockchain/OnChainWallet.scala 100.00% <ø> (ø)
...ir/blockchain/bitcoind/rpc/BitcoinCoreClient.scala 89.79% <100.00%> (+0.21%) ⬆️
...inq/eclair/channel/fund/InteractiveTxBuilder.scala 91.83% <100.00%> (-0.65%) ⬇️
...cinq/eclair/channel/publish/MempoolTxMonitor.scala 87.20% <100.00%> (ø)
...ir/channel/publish/ReplaceableTxPrePublisher.scala 71.15% <100.00%> (ø)
.../acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala 82.50% <80.00%> (-1.43%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sstone
sstone force-pushed the use-txospenderindex branch from 19e21c3 to 7c932d7 Compare August 27, 2026 07:44
…r channels

On startup, eclair will check that both txindex and txospenderindex are enabled and synced, and will stop if they're not.
Block scanning code used to find spending transactions is removed, we just use the txospenderindex now.

Te add a new RetryCheckSpent watch hint to retry finding transaction spenders when the first check
was inconclusive (because a RPC call failed for example) or when RPC calls returned inconsistent results, so
we can check again at every new block.

For external channels, where there is no risk of losing funds, we don't retry (but we will when we restart).
@sstone
sstone force-pushed the use-txospenderindex branch from 7c932d7 to e6f0935 Compare August 27, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants