Page MenuHomePhabricator

[chronik] Electrum: implement the blockchain.transaction.id_from_pos endpoint
ClosedPublic

Authored by Fabien on Jun 3 2025, 16:19.

Details

Event Timeline

Fabien requested review of this revision.Jun 3 2025, 16:19
bytesofman requested changes to this revision.Jun 3 2025, 18:31
bytesofman added a subscriber: bytesofman.

blockchain-transaction-id-from-pos

TIL

chronik/chronik-http/src/electrum.rs
1676 ↗(On Diff #54310)

if we have special error conditions here, we should test them

1680 ↗(On Diff #54310)

ditto

1688 ↗(On Diff #54310)

ditto

1712 ↗(On Diff #54310)

i think this return is not tested

test/functional/chronik_electrum_blockchain.py
576 ↗(On Diff #54310)

this is bc block 33 does not exist right?

if so, should add another test confirming we also get the expected error in an existing block if just the position does not exist

let tx_count = 42
assert_equal(
            self.client.blockchain.transaction.id_from_pos(self.node.getblockcount(), tx_count+1).error,
            {
                "code": 1,
                "message": "No transaction at position 43 for height <height>",
            },
        )
This revision now requires changes to proceed.Jun 3 2025, 18:31
chronik/chronik-http/src/electrum.rs
1676 ↗(On Diff #54310)

Yes the same code is covered in other similar endpoints, but it can't hurt to repeat the test.

test/functional/chronik_electrum_blockchain.py
576 ↗(On Diff #54310)

It ends up being the same message if the block doesn't exist and/or the tx index is out of bounds. I will expand the test to cover both cases.
Block 33 likely exists in this test, I didn't check because I'm sure there is no 806th tx. As per the choice for the numbers, only some old frenchies can get it.

Better coverage for parsing error

bytesofman added inline comments.
test/functional/chronik_electrum_blockchain.py
576 ↗(On Diff #54310)

grok has theories

image.png (768×1 px, 1 MB)

image.png (442×330 px, 350 KB)

This revision is now accepted and ready to land.Jun 3 2025, 21:05
Fabien marked 3 inline comments as done.Jun 3 2025, 21:11
Fabien added inline comments.
test/functional/chronik_electrum_blockchain.py
576 ↗(On Diff #54310)

The first one is correct, it's from an old ad for this car

This revision was landed with ongoing or failed builds.Jun 3 2025, 21:13
This revision was automatically updated to reflect the committed changes.