Skip to content

Support Ergo nodes without extra indexing - #72

Merged
kushti merged 2 commits into
BetterMoneyLabs:masterfrom
odybhoja:support-non-indexed-node
Nov 11, 2026
Merged

kushti merged 2 commits into
BetterMoneyLabs:masterfrom
odybhoja:support-non-indexed-node

Conversation

@odybhoja

@odybhoja odybhoja commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Support Ergo nodes without extra indexing

chaincash required a node with extra indexing (extraIndex = true): the
server panicked at startup without /blockchain/indexedHeight, and note
scanning, note redemption and the healthcheck all used the indexer API.

Add ChainSource, which detects whether the node is indexed and otherwise
falls back to APIs every node exposes:

  • transactions via /blocks/at/{height} + /blocks/{id}/transactions,
    using the box inclusion height reported by scans
  • spent/unspent note and reserve boxes via /scan/unspentBoxes and
    /scan/spentBoxes
  • oracle and buyback boxes via containsAsset scans registered at
    startup, checked against /utxo/withPool/byId because scans can report
    spent boxes as unspent (e.g. when the node skips blocks during a
    wallet rescan)

Also fix startup on Ergo node 6.x, indexed or not: /script/p2sAddress
now requires treeVersion, which ergo_client does not send. Contracts are
compiled with treeVersion 0, which matches the trees deployed on mainnet.

The healthcheck now reports node info from /info, plus the indexed
height when indexing is enabled.

ServerState::new now takes the node API key, needed for endpoints that
ergo_client does not wrap.

Tested against an Ergo 6.0.7 mainnet node bootstrapped from a UTXO
snapshot, with extraIndex = false.

Closes #71

@odybhoja
odybhoja force-pushed the support-non-indexed-node branch from 201b775 to 545d2bb Compare November 9, 2026 10:12
Previously the server panicked at startup if /blockchain/indexedHeight
was unavailable, and note scanning, note redemption and the healthcheck
all relied on the indexer API.

Add a ChainSource that detects whether the node has extra indexing and
falls back to scan- and block-based lookups when it does not:
- transactions are fetched via /blocks/at/{height} using the box
  inclusion height
- spent/unspent note and reserve boxes are looked up from node scans
  (/scan/unspentBoxes, /scan/spentBoxes)
- oracle and buyback boxes are found through ContainsAsset scans that
  are registered at startup (triggering a wallet rescan)

The healthcheck now reports node info from /info and includes the
indexed height only when indexing is enabled.

ServerState::new now takes the node API key, needed for the
/scan/spentBoxes endpoint which ergo_client does not wrap.
Ergo node 6.x requires a treeVersion field in /script/p2sAddress, which
ergo_client does not send, so the server failed at startup against any
6.x node. Compile contracts through ChainSource with treeVersion 0, which
reproduces the contract trees deployed on mainnet.

Node scans can report spent boxes as unspent, e.g. when the node skips
blocks during a wallet rescan (seen on a 6.0.7 UTXO-bootstrapped node).
Confirm oracle/buyback candidates against /utxo/withPool/byId before
using them.

Add ignored tests that run against a live node on localhost:9053.
@odybhoja
odybhoja force-pushed the support-non-indexed-node branch from 545d2bb to 3a3b3a9 Compare November 9, 2026 10:32
@kushti
kushti merged commit dcbc800 into BetterMoneyLabs:master Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server requires Ergo node extra indexing to run

2 participants