Skip to content

rpcclient: add GetTxOutProof{,Async} methods, speed up string parsing#2489

Open
guggero wants to merge 2 commits intobtcsuite:masterfrom
guggero:gettxoutproof
Open

rpcclient: add GetTxOutProof{,Async} methods, speed up string parsing#2489
guggero wants to merge 2 commits intobtcsuite:masterfrom
guggero:gettxoutproof

Conversation

@guggero
Copy link
Copy Markdown
Collaborator

@guggero guggero commented Mar 1, 2026

Adds a new method to fetch transaction output inclusion proofs.

While observing this code and specifically the GetBlock method on mainnet, I observed a lot of JSON-related memory allocations for basically turning "<hex_string>" into <hex_string>. So I changed those JSON parse calls with simple prefix/suffix string replacements, which should hopefully be much faster and require fewer allocations.

@saubyk saubyk requested a review from kcalvinalvin March 2, 2026 20:36
@Roasbeef Roasbeef added this to the v0.25.1 milestone Mar 10, 2026
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Two main comments:

  1. Extract to helper function
  2. Tests for the expected output

guggero added 2 commits March 25, 2026 12:44
This commit replaces the parsing of a JSON string with a simple
prefix/suffix replacement of the quotes. That is much faster than
allocating memory for a JSON parser.
Where possible, we also directly decode the hex with a decoder to
further reduce the number of allocations.
@guggero
Copy link
Copy Markdown
Collaborator Author

guggero commented Mar 25, 2026

Thanks for the review! I guess I was a bit lazy with this PR... Addressed your comments.

@guggero guggero requested a review from Roasbeef March 25, 2026 11:45
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.

2 participants