Skip to content

fix(firo, insight): index Spark name fee outputs; stock Insight fields and 404s - #37

Merged
stultusmundi merged 3 commits into
masterfrom
fix/firo-sparkname-fee-insight-gaps
Oct 30, 2026
Merged

stultusmundi merged 3 commits into
masterfrom
fix/firo-sparkname-fee-insight-gaps

Conversation

@stultusmundi

Copy link
Copy Markdown
Collaborator

Fixes from the FIRO-02 A/B run of the Insight listener against stock insight-api-zcoin 0.4.5.

Firo

  • Spark name fee outputs are indexed. Since about block 1.3M, Spark name registrations pay the dev fund with a P2PKH script followed by OP_SPARKNAMEID <name> OP_DROP <spark address> OP_DROP. Blockbook couldn't read it, so aFA2TbqG9cnhhzX5Yny2pBJRK5EaEqLCH7 was missing 163 txs (488 FIRO) and a utxo. The parser now indexes these outputs under the P2PKH address descriptor, using the same rule as firod's IsSparkNameFee. Other scripts are unchanged. Tests use the real script from tx 01676aed….
    • Needs a full resync on nodes that indexed past ~1.3M (-rollback only goes back 300 blocks). A node still below that height only needs the new package.
  • The Firo Insight extension no longer inserts a synthetic "sparkname" output, so vout n is the on-chain index. sparkData is still returned.
  • scriptPubKey.type is expubkeyhash for exchange outputs and pubkeyhash for Spark name fee outputs.
  • The masternode filter accepts a JSON array like stock (200 []), within the existing caps.

Insight listener (all coins)

  • utxo rows include scriptPubKey. It's derived from the address descriptor, so a P2PK output shows its P2PKH script.
  • vout scriptPubKey.type is filled in.
  • status includes network, testnet and relayfee (from getnetworkinfo, cached).
  • Unknown paths under /api/ and /insight-api/ return the Insight 404 with CORS instead of the -insightui fallback. /api/v1/ and /api/v2/ still reach the explorer.

Not included

  • spentTxId/spentIndex/spentHeight stay null without -extendedindex.
  • extraPayload/cbTx would need one daemon call per tx.

Tests

go test -tags unittest ./bchain/coins/firo/... ./server/... passes in the blockbook-build image, including the Insight tests under -race. gofmt is clean.

Spark name registrations (type 11, from about block 1,300,000) pay the fee
to a script that is a P2PKH script followed by OP_SPARKNAMEID <name> OP_DROP
<spark address> OP_DROP. firod reports it as sparknamefee with the P2PKH
address; the parser derived no address, so these outputs were indexed under
the full script and the dev fund aFA2TbqG... missed 163 txs and their utxos.

GetAddrDescFromVout now returns the leading 25-byte P2PKH script for exactly
firod's CScript::IsSparkNameFee template, so balance, history and utxos merge
with plain payments to the address, and the address decoding shows it on the
raw, mempool and JSON paths. Any other script is unchanged.

Already indexed blocks keep the old descriptor: resync from before the first
Spark name fee output.
The Firo extension inserted the newer upstream explorer's synthetic
"sparkname" output at n=0 and renumbered the outputs, so tx/:txid vout n was
one higher than the on-chain index on Spark name registrations. The deployed
stock insight-api-zcoin 0.4.5 does not do that. The output is no longer
inserted; sparkData is still added.

Exchange outputs get scriptPubKey.type expubkeyhash and Spark name fee
outputs pubkeyhash, as stock.

A JSON array masternode filter now does what stock's code does with it (the
elements joined by a comma as one substring, so usually 200 []) instead of a
400; an array stock throws on, or with non-string elements, is still a 400.
The 4 KiB filter cap applies to the joined string.
- utxo rows carry scriptPubKey, the hex output script of the address's
  index descriptor (no per-output lookup); the listener gets the chain
  parser for it.
- vout scriptPubKey.type is classified from the script with stock's names
  (pubkeyhash, scripthash, witnesspubkeyhash, witnessscripthash, taproot,
  plus nulldata and multisig) unless a coin label is set.
- status getInfo adds network and testnet from the daemon's chain and
  relayfee from getnetworkinfo (cached 10 minutes, left out on failure).
- With -insightui, unknown paths under /api/ and /insight-api/ are the
  Insight JSON 404 with CORS headers, as stock, instead of the public
  server's /api/ status page; /api/v1/ and /api/v2/ still fall through.
- The unused empty-script JSON special case for the synthetic sparkname
  output is removed.

spentTxId/spentIndex/spentHeight stay null without Blockbook's extended
index (Firo, ZEC); extraPayload/cbTx are not in the index. Both are documented
in docs/insight-compatibility.md.
@stultusmundi
stultusmundi merged commit 86cc8f3 into master Oct 30, 2026
4 checks 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.

1 participant