Fix: blockchain.transaction.id_from_pos compatibility with electrs - #222
Open
jharveyb wants to merge 2 commits into
Open
Fix: blockchain.transaction.id_from_pos compatibility with electrs#222jharveyb wants to merge 2 commits into
jharveyb wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on a lightning
GossipVerifierin ldk-node, I ran into an issue with the Electrum client.tl;dr electrs diverges from the Electrum protocol a bit, such that the blockchain.transaction.id_from_pos method doesn't work right now. Fixing this is pretty simple.
There are two issues: the 3rd parameter,
merkle, not being treated as optional, and the return value formatting whenmerkle = false.To reproduce, you can run the relevant test against an electrs/0.11.1 server found on https://1209k.com/bitcoin-eye/ele.php, (not qtornado, which is ElectrumX):
If the library adds the
merkle = falseparameter, there is still an issue with parsing the response:You can see the electrs behavior here:
https://github.com/romanz/electrs/blob/9cd09afa229df89214f59816e5142f0f58ff6c48/src/electrum.rs#L466
Additionally, the JSON map key was
tx_idbefore version 0.11.1:https://github.com/romanz/electrs/blob/800bebeea4a3ec4ca924b389338b3449c81b28d4/src/electrum.rs#L484
This PR accepts both versions. You can confirm that behavior with a public electrs v0.10.9 server (I didn't get this working with the cargo test runner):
Added tests for the parsing, and the raw_client:
Everything is passing locally for me, though that electrum.tjader.xyz server seems finicky. I also tested this branch in my electrum CLI and confirmed it works against both my personal electrs server, and
electrum.blockstream.info.Something like https://github.com/testcontainers/testcontainers-rs could be useful for testing against multiple impls if there's no public (reliable) electrs instance.