Page MenuHomePhabricator

[chronik] Electrum: Implement the *.get_first_use endpoints
ClosedPublic

Authored by Fabien on May 26 2025, 20:05.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC374de45c36e3: [chronik] Electrum: Implement the *.get_first_use endpoints
Summary

https://electrum-cash-protocol.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-get-first-use

Note that fulcrum returns a duplicated field for this request (height and block_height) but we only follow the specification.

Depends on D18153.

Test Plan
./test/functional/test_runner.py chronik_electrum_blockchain

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.May 26 2025, 20:05
PiRK added inline comments.
chronik/chronik-http/src/electrum.rs
1720–1721 ↗(On Diff #54196)

inconsistent comments (=)

1752–1759 ↗(On Diff #54196)

I don't see this sorting mentioned in the spec. Is this for test determinism?

test/functional/chronik_electrum_blockchain.py
741 ↗(On Diff #54196)

unused indexing

761–763 ↗(On Diff #54196)

misplaced duplicated test?

PiRK requested changes to this revision.May 27 2025, 07:00
This revision now requires changes to proceed.May 27 2025, 07:00
chronik/chronik-http/src/electrum.rs
1752–1759 ↗(On Diff #54196)

It's not in the spec. This is based on the observed ordering of fulcrum across the various endpoints where it's sorted by block height first then txid. In this case the block height is always the same so I used txid. This is still compliant with the spec since:

For multiple mempool transactions referencing the same script hash, an unspecified transaction will be arbitrarily chosen and it may not always be the first one that appeared in the mempool for this script hash.

test/functional/chronik_electrum_blockchain.py
741 ↗(On Diff #54196)

Good catch, a leftover from a previous iteration of the test

761–763 ↗(On Diff #54196)

A copy pasta error I guess

This revision is now accepted and ready to land.May 27 2025, 08:21