Commit graph

72 commits

Author SHA1 Message Date
Hossein Zoda
f9ee877392 format 2026-06-23 02:38:25 +03:00
Hossein Zoda
0831834d8f ido: replace txchain model with unified state-chain indexing
Replace index_block/index_mempool with a single index_txs that takes an
Option<blockhash> (Some for confirmed, None for mempool). Add
delete_entries(blockhash) for reorg undo and to drop stale mempool state
before applying confirmed blocks. Replace has_txchain_tx with
has_indexed_tx; chain-follow now keys on ido_state.next_output_index
instead of the removed tracker map.

Remove the debug-only txchain RPC endpoints and the debug config gating.
Keep txchain_head as a public RPC field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 19:46:23 +00:00
Hossein Zoda
9b0a54c926 ido: maintain entry aggregates in active state
Replace the per-request get_ido_entry_aggregates SQL scan with running
totals carried in IdoActiveState: totalDemandAmount, totalSupplyAmount,
and totalDiscount. Initialized to 0 at the preinit->active transition and
incremented on each entry added; the rebuild path recomputes them by
replaying the txchain, so they self-heal.

Drop the now-unused get_ido_entry_aggregates DB fn, the IdoEntryAggregatesRpc
type, the /<id>/aggregates RPC handler, and its route registration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
aec0a6f0f8 ido: add /<id>/aggregates endpoint for entry totals
Sum demand/supply amounts and count entries for an IDO, used to show
"raised so far" for active offerings where on-chain state keeps no
running total.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
7f46b1b4b7 ido: index unconfirmed txs from the mempool
- electrum mempool fetch gains an ido filter: state machine spends
  (IDO_SIGNATURE in scriptsig) union preinit announcements
  (IDO_PREINIT_ANNOUNCEMENT_SIGNATURE in scriptpubkey)
- split tx scanning out of index_block into index_txs and add
  index_mempool, which indexes with a -1 sentinel height;
  txchain_trim_tracker leaves negative heights alone and the real
  height replaces the sentinel once the tx confirms in a block
- block indexing now skips re-creating an ido already seen in the
  mempool, only updating its tracker height
- mempool txs are kahn-sorted so txchain parents index before children

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
b56ce5bc63 ido: key txchain tx lookup by txid; gate debug endpoints behind config
Change get_txchain_tx to take the public txid (a unique field) instead of
the non-public internal txchain item id, and promote it to a production
endpoint. Mount the two remaining debug endpoints (list_ido_txchain,
list_txchain_tracker_map) only when `debug = true` in the config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
988426e485 ido, compiles, with claude generated unittests 2026-06-21 01:44:39 +03:00
Hossein Zoda
0629e168c3 ido incomplete c02 2026-06-21 01:44:39 +03:00
Dagur Valberg Johannsson
9d0eaff22c
tokentoken: add GET /tokentoken/pools (list all active pools)
List every active TokenToken pool (no pair filter) so the frontend can
present the set of pooled token pairs without probing each candidate pair.
Mirrors db_active_pools_for_pair minus the pair WHERE clause; served at a
distinct /pools path (the param'd /pool/active already matches param-less
requests via its Option guards, so reusing it would collide).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 13:48:45 +02:00
Dagur Valberg Johannsson
1614b84674 Upgrade bitcoincash to 0.32 and add TokenToken AMM pool indexing
Migrate off the deprecated bitcoincash 0.29 API (Amount/Version types,
FromHex -> FromStr/parse, non-exhaustive Network) across the indexer and
tests.

Add indexing of native token-A <-> token-B (TokenToken) AMM pools:

- tokentoken_pool / tokentoken_pool_history_entry tables in cauldron.db,
  created via an always-run idempotent migration (no DB_VERSION bump, so
  existing databases upgrade in place)
- block-path indexing sharing the cauldron write transaction and reorg
  undo, with creation/swap/withdrawal state tracking and reserve deltas
- mempool indexing: electrum mempool.get filters on the tokentoken
  contract code (spends) and the CONJURE op_return hint (creations);
  first_seen_timestamp reconciles with mtp on confirmation
- RPC endpoints /tokentoken/pool/active (pair lookup, order-insensitive)
  and /tokentoken/tokens

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 16:18:35 +02:00
jakobsn
dd4ffb5e3b Remove oracle_cash quickfix introduced Apr 24 2026 2026-06-09 13:18:53 +00:00
jakobsn
f56cc16d93 using oracles cash feed 2026-04-24 05:19:43 +00:00
Dagur Valberg Johannsson
c7eb5bcc36 Added support for indexing Moria contracts 2026-03-30 23:52:29 +02:00
jakobsn
bcab4db2fe Cachecandles 2026-03-25 11:38:10 +00:00
Dagur Valberg Johannsson
f421327a5d
Switch to tokio and sqlx
This makes the application fully async; freeing web server threads to
handle new connections when waiting on SQL queries.

Additionally sqlx will allow easier move to a different database if
needed in the future.

Includes some SQL optimizations as well (slow queries more easliy identifiable
with sqlx).
2026-02-18 10:16:51 +01:00
Dagur Valberg Johannsson
3ff73473df
Add /health endpoint 2026-02-10 15:36:21 +01:00
Dagur Valberg Johannsson
bac43bbb98
Make DB read pool size configurable 2026-02-10 14:49:28 +01:00
Dagur Valberg Johannsson
7ad0303209
Add WebSocket support 2026-02-03 09:39:12 +01:00
Dagur Valberg Johannsson
d8929dc913 Merge branch 'crc20-fix' into 'master'
Fix cross-database query bug in CRC20 BCMR filtering

See merge request riftenlabs/riftenlabs-indexer!61
2026-02-02 20:11:19 +00:00
Dagur Valberg Johannsson
b32a3e54cc Fix cross-database query bug in CRC20 BCMR filtering
The previous commit tried to query bcmr_data table from the crc20
database connection, but bcmr_data exists only in the bcmr database.

Fix by introducing STATE_SKIP_HAS_BCMR to mark tokens that have BCMR
data. The CRC20 fetcher now queries the bcmr database separately to
find candidates with BCMR data, marks them in the crc20 database, and
skips them in future iterations.
2026-02-02 21:03:11 +01:00
Dagur Valberg Johannsson
2b29590211
Do not serve requests during IBD
Do not serve old data; reject RPC requests during IBD.
2026-02-02 12:08:04 +01:00
Dagur Valberg Johannsson
d85bc2c9db
Update copyright headers 2026-01-21 12:37:13 +01:00
Dagur Valberg Johannsson
ec20a2ad75 Add graceful shutdown for background threads
Introduce a shutdown flag and Rocket fairing that signals background
threads to exit cleanly when Ctrl+C is pressed. Affects the indexing
thread, metrics updater, and block receiver loop.
2026-01-21 12:23:08 +01:00
Dagur Valberg Johannsson
50cd23dd34
Add RPC call to retrieve pool ID
Add a call that returns a pool ID given an utxo
2026-01-09 15:29:05 +01:00
Dagur Valberg Johannsson
a6c6159eba
Add Chipnet support 2026-01-09 13:46:58 +01:00
jakobsn
885dde9534 Resolve "Panic occurred: attempt to multiply with overflow" 2025-10-03 13:32:37 +00:00
Jakob Notland
7e7f5b9bc7 Expose first pool created timestamp 2025-09-17 11:11:21 +02:00
jakobsn
f83f472656
Goodsearchandsort 2025-09-05 13:53:10 +00:00
Dagur Valberg Johannsson
14a7486c1d
rpc: Add /volume endpoints
Add /volume endpoints that use the new token/sats delta entries for
faster volume queries.
2025-08-18 09:53:40 +02:00
Dagur Valberg Johannsson
6c13775475
Add simple db version check 2025-08-15 22:26:03 +02:00
Dagur Valberg Johannsson
e2cd74f68c
Delay CRC20 indexing
Delay indexing CRC20 details; as the electrum queries can be slow and
interfere with the indexing.
2025-08-15 21:06:35 +02:00
Dagur Valberg Johannsson
7d9352cf53
Fix clippy issues 2025-07-16 13:52:46 +02:00
jakobsn
b17b8a3947 Resolve "Oracle prices" 2025-06-17 14:04:26 +00:00
Dagur Valberg Johannsson
3d83bdee47 Merge branch 'candlesticks2' into 'master'
Candlesticks2

See merge request riftenlabs/riftenlabs-indexer!20
2025-06-17 13:22:46 +00:00
jakobsn
d1e265cf2f Candlesticks2 2025-06-17 13:22:46 +00:00
Dagur Valberg Johannsson
8b16e3d1f3
bump minor deps 2025-06-12 10:08:22 +02:00
Dagur Valberg Johannsson
78e391560f
Added support for delphi oracle
This allows fetching historical asset prices from the blockchain.
2025-05-21 13:33:26 +02:00
Dagur Valberg Johannsson
ebe63ce932
Improve db initialization 2025-02-14 18:35:12 +01:00
Dagur Valberg Johannsson
33aebb0318
bug: Foreign keys not enforced
sqlite was not properly enforcing foreign keys, keeping conflicted
transactions in the database
2024-12-19 13:21:57 +01:00
Dagur Valberg Johannsson
b1e88ff261
rpc: Add pool history call 2024-11-13 11:28:27 +01:00
jakobsn
1248929fb4 Search tokens 2024-10-31 10:55:29 +00:00
Dagur Valberg Johannsson
b4b9bf1eb5
Make rostrum server configurable
New default set to localhost
2024-10-25 15:22:44 +02:00
Dagur Valberg Johannsson
e4e7ec3b71
Add aggregated APY endpoint
Add an endpoint that gives a APY value across multiple micro-pools
2024-10-23 16:54:06 +02:00
Dagur Valberg Johannsson
751c1df6a7
Add CRC20 index 2024-10-21 13:35:24 +02:00
jakobsn
07c75b1a7e Tokens page 2024-10-14 11:18:50 +00:00
Dagur Valberg Johannsson
5aebe7bdaf
Use package electrum-client-netagnostic
Replace package that pointed at a git repo with
electrum-client-netagnostic.
2024-10-08 22:15:46 +02:00
Dagur Valberg Johannsson
528cc79725
API call for latest transactions 2024-09-25 13:39:06 +02:00
Dagur Valberg Johannsson
cd6ce4d4ef
Add well-known BCMR sources
This adds additional BCMR data sources, mainly OTR.
2024-09-10 22:39:30 +02:00
Dagur Valberg Johannsson
675b3f08f9
rpc: Unique addresses
RPC method to show number of unique addresses interracting with cauldron
2024-09-04 13:25:36 +02:00
Dagur Valberg Johannsson
3ba04dfd58
Cache list_by_volume call
This is an expensive call used by all users of Cauldron DEX; cache for
60 seconds.
2024-05-29 08:46:35 +02:00