Commit graph

244 commits

Author SHA1 Message Date
Hossein Zoda
856b374a6d ido improvements & fixes (WIP) 2026-06-21 01:44:39 +03:00
Hossein Zoda
b1df63c6c4 ido: garbage collect tracker entries of mempool txs that never confirm
Stamp mempool tracker entries with the negative of the highest known
block height instead of a fixed -1 sentinel, and trim on abs(height) so
entries whose tx is invalidated before confirming (e.g. by a double
spend) age out after TRACKER_MAX_BLOCK_DEPTH like confirmed ones. The
height is still replaced with the real one once the tx confirms.

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
e14fbd4f1e ido more fixes 2026-06-21 01:44:39 +03:00
Hossein Zoda
874e9f0231 set mock platform fee nfthash 2026-06-21 01:44:39 +03:00
Hossein Zoda
366823cf02 ido: validate delphi nft in preinit first output; announcement moves to last
The preinit tx layout changed: the first output is now the Delphi NFT and
the announcement OP_RETURN is the last output. Read the announcement from the
last output in both is_preinit_broadcast and parse_ido_preinit_tx_params.

Add validity checks on the first output's Delphi NFT: its category must match
the announcement's delphiCategory, and the 48-bit commitment timestamp (current
time) must place launchConditions.expiresAt within a 1-30 day window.

The two PREINIT_TEST_TX vectors use the old layout, so the three preinit parse
tests are marked #[ignore] pending new-format sample transactions.

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
e86de7d5f5 ido: hide txchain_entrypoint, expose txchain_head as head txid
The IDO RPC record no longer leaks internal txchain row ids. Drop the
txchain_entrypoint field entirely, and change txchain_head from the
internal ido_txchain.id to the head record's txid (display hex).

list_idos and get_ido_by_offering_token_id resolve this in a single
query via LEFT JOIN ido_txchain ON head_tx.id = ido.txchain_head; a
NULL head yields null. Adds tests for both the resolved and null cases.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
6728753db0 ido: use preinit_txid hex as public id (rename internal id)
Rename ido.id -> ido.internal_id in the schema and IdoDBRecord, and
expose the preinit_txid hex as the public "id" in all RPC responses.

Public API shape:
  - IdoRpcRecord.id: i64 -> String (hex of preinit_txid). preinit_txid
    field is preserved unchanged.
  - IdoEntryRpcRecord.ido_id: i64 -> String (hex of parent preinit_txid).
  - IdoTxChainRpcRecord.ido_id: i64 -> String (hex of parent preinit_txid).
  - IdoTxChainRpcRecord gains ido_internal_id: i64 (debug endpoint only).
  - Routes /<id>/entries and /<id>/txchain accept the preinit_txid hex
    as the path id; returns 404 IDO_NOT_FOUND on miss.

Internals:
  - New lookup_internal_id_by_preinit_txid helper.
  - list_ido_entries / list_ido_txchain take preinit_txid_hex as input
    so the caller (which already parsed it from the path) avoids the
    extra "preinit_txid by internal_id" lookup.
  - Child table FK columns (ido_entry.ido_id, ido_txchain.ido_id) keep
    their names; only the parent PK and field accesses were renamed.

Notes:
  - Breaking API change for /ido/* endpoints. Clients reading "id" or
    "ido_id" as integers must switch to strings.
  - ido.db has no migration framework: drop the file and re-index on
    deploy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-21 01:44:39 +03:00
Hossein Zoda
210a51f274 ido bcmr ser/deser fixes 2026-06-21 01:44:39 +03:00
Hossein Zoda
c4eaad4cec ido more fixes +two unittests 2026-06-21 01:44:39 +03:00
Hossein Zoda
a944db4702 ido better error reporting 2026-06-21 01:44:39 +03:00
Hossein Zoda
f8ddac6ec3 followup update for ido -> adding ipfs bcmr placeholder 2026-06-21 01:44:39 +03:00
Hossein Zoda
335818460f followup changes to ido contracts 2026-06-21 01:44:39 +03:00
Hossein Zoda
3f8a9cd026 ido more fixes 2026-06-21 01:44:39 +03:00
Hossein Zoda
aa99f775da tiny fix 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
Hossein Zoda
ce9dba23cf (WIP) ido 2026-06-21 01:44:39 +03:00
Dagur Valberg Johannsson
84a8fc4662 Merge branch 'tt-list' into 'master'
tokentoken: add GET /tokentoken/pools (list all active pools)

See merge request riftenlabs/riftenlabs-indexer!90
2026-06-18 10:37:03 +00: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
5d141a51fb Merge branch 'bitcoincash-0.32.2' into 'master'
Update bitcoincash to 0.32.2 and riftenlabs-defi to 0.4.1

See merge request riftenlabs/riftenlabs-indexer!89
2026-06-10 21:17:33 +00:00
Dagur Valberg Johannsson
dc420424ac Update bitcoincash to 0.32.2 and riftenlabs-defi to 0.4.1
Fixes the indexer crash on chipnet: bitcoincash 0.32.1's
Opcode::classify panicked on BCH re-enabled opcodes (e.g. OP_SPLIT),
which riftenlabs-defi hit while parsing input scriptSigs in
parse_cauldrons_from_tx. bitcoincash 0.32.2 makes classify total and
panic-free (and adds the May 2026 upgrade opcodes); riftenlabs-defi
0.4.1 additionally hardens read_push_from_script to not classify
non-push opcodes at all.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 22:58:53 +02:00
Dagur Valberg Johannsson
9c1fd7550f Merge branch 'tokentoken' into 'master'
Upgrade bitcoincash to 0.32 and add TokenToken AMM pool indexing

See merge request riftenlabs/riftenlabs-indexer!88
2026-06-10 14:53:03 +00: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
d0aec39d90 Merge branch 'useDelphiForIndexer' into 'master'
Remove oracle_cash quickfix introduced Apr 24 2026

See merge request riftenlabs/riftenlabs-indexer!87
2026-06-09 13:18:54 +00:00
jakobsn
dd4ffb5e3b Remove oracle_cash quickfix introduced Apr 24 2026 2026-06-09 13:18:53 +00:00
jakobsn
d8edfe15fb Merge branch 'chartImprovementFirstSeen' into 'master'
Use first time seen for phe same as transactions to make the live price chart sensible.

See merge request riftenlabs/riftenlabs-indexer!85
2026-05-08 14:24:18 +00:00
Jakob Notland
071bd3552b Use first time seen for phe same as transactions to make the live price chart sensible. 2026-05-07 14:25:52 +02:00
Dagur Valberg Johannsson
7fbe2b2b79 Merge branch 'delphi-v2' into 'master'
Delphi v2 support

See merge request riftenlabs/riftenlabs-indexer!84
2026-05-04 21:49:48 +00:00
Dagur Valberg Johannsson
4d205cada4
Delphi v2 support
Same API from consumer-standpoint
2026-05-04 15:03:40 +02:00
Dagur Valberg Johannsson
4fe4492620 Merge branch 'well-known-bug' into 'master'
bcmr: Look for well-known on bare domains

Closes #24

See merge request riftenlabs/riftenlabs-indexer!83
2026-04-29 08:39:48 +00:00
Dagur Valberg Johannsson
2633166705
bcmr: Look for well-known on bare domains
According to BCMR spec, if bare domains are un op_return, we should look
up "well known" path for the domain.

Fallback to previous behaviour if well known is not found.
2026-04-29 10:35:34 +02:00
jakobsn
00a28f71c0 Merge branch 'oraclesCashDirectly' into 'master'
using oracles cash feed

See merge request riftenlabs/riftenlabs-indexer!82
2026-04-24 05:19:43 +00:00
jakobsn
f56cc16d93 using oracles cash feed 2026-04-24 05:19:43 +00:00
jakobsn
22f890d6ff Merge branch '4-price-token-at-timestamp-does-not-count-previously-active-pools' into 'master'
Count pools that were not withdrawn at the given time.

Closes #4

See merge request riftenlabs/riftenlabs-indexer!80
2026-04-16 12:35:15 +00:00
jakobsn
460794f067 Count pools that were not withdrawn at the given time. 2026-04-16 12:35:15 +00:00
Dagur Valberg Johannsson
37779e68f8 Merge branch 'moria' into 'master'
Added support for indexing Moria contracts

See merge request riftenlabs/riftenlabs-indexer!77
2026-04-08 08:27:33 +00:00
Dagur Valberg Johannsson
c7eb5bcc36 Added support for indexing Moria contracts 2026-03-30 23:52:29 +02:00
jakobsn
3996264bd3 Merge branch 'cacheCandles' into 'master'
Cachecandles

See merge request riftenlabs/riftenlabs-indexer!78
2026-03-25 11:38:10 +00:00
jakobsn
bcab4db2fe Cachecandles 2026-03-25 11:38:10 +00:00
jakobsn
a1753deedb Merge branch '23-dormant-pools-report-inflated-apy-due-to-end-snapshot-not-clamped-to-window-boundary' into 'master'
dormant-pools-report-inflated-apy

Closes #23

See merge request riftenlabs/riftenlabs-indexer!76
2026-03-19 08:55:51 +00:00
jakobsn
15f7331867 dormant-pools-report-inflated-apy 2026-03-19 08:55:51 +00:00
jakobsn
9130c43dbf Merge branch '20-alternative-solution' into 'master'
Commit alternative solution for pool inflation

Closes #20

See merge request riftenlabs/riftenlabs-indexer!74
2026-03-11 09:31:21 +00:00
jakobsn
381cb94295 Commit alternative solution for pool inflation 2026-03-11 09:31:21 +00:00
jakobsn
87ba024a04 Merge branch '21-return-aapy-for-an-array-of-pkhs' into 'master'
Resolve pool id array aapy

Closes #21

See merge request riftenlabs/riftenlabs-indexer!71
2026-03-06 12:08:18 +00:00
jakobsn
1877b09b47 Resolve pool id array aapy 2026-03-06 12:08:15 +00:00
Dagur Valberg Johannsson
79e8968ef0 Merge branch 'update-docs' into 'master'
Document improvements

See merge request riftenlabs/riftenlabs-indexer!70
2026-02-24 10:43:59 +00:00
Dagur Valberg Johannsson
e8371c3967
Document improvements
Misc improves to API documentation
2026-02-24 11:39:20 +01:00
Dagur Valberg Johannsson
18c0f41a58 Merge branch 'bump-electrum' into 'master'
Bump electrum dep to allow larger websocket msg

See merge request riftenlabs/riftenlabs-indexer!69
2026-02-24 09:35:02 +00:00