fix(electrum): do not pick unindexed outputs for history lookup#2195
Open
zoedberg wants to merge 1 commit intobitcoindevkit:masterfrom
Open
fix(electrum): do not pick unindexed outputs for history lookup#2195zoedberg wants to merge 1 commit intobitcoindevkit:masterfrom
zoedberg wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
evanlinjin
requested changes
Apr 29, 2026
Member
evanlinjin
left a comment
There was a problem hiding this comment.
Good catch!
Also, can you rebase on master to fix CI.
| .expect("tx must have an output") | ||
| .clone(); | ||
| .iter() | ||
| .find(|txo| !txo.script_pubkey.is_op_return()) |
Member
There was a problem hiding this comment.
We should also filter out OP_FALSE OP_RETURN since that's used in ephemeral anchors and is excluded from the ElectrumX index.
Author
There was a problem hiding this comment.
you're right, sorry I missed that, fixed!
85c2bfe to
6d689c9
Compare
Author
|
@evanlinjin Fixed and rebased |
evanlinjin
requested changes
Apr 29, 2026
| .then(|| script.clone()) | ||
| }) { | ||
| Some(spk) => spk, | ||
| None => continue, |
Member
There was a problem hiding this comment.
This means some txs will not be fetched even though they are provided by txids and they exist.
We may need to fetch a parent tx in order to obtain a spk that we can fetch history with.
Author
There was a problem hiding this comment.
it makes sense, thanks for the suggestion. please check if the fix is ok now
6d689c9 to
88b1354
Compare
88b1354 to
2e3d52e
Compare
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.
Description
BdkElectrumClient::populate_with_txidsqueries each transaction's confirmation status by callingscript_get_historyon the script of one of its outputs. It currently picks the first output unconditionally. This breaks for transactions which first output is anOP_RETURN, because Electrum servers don't indexOP_RETURNscripts and will return an empty history. This is a real-world scenario: protocols like RGB place anOP_RETURNcommitment as the first output of every transaction.Notes to the reviewers
The fix selects the first output which script is not
OP_RETURNor aOP_FALSE OP_RETURN. If a transaction has onlyOP_RETURN/OP_FALSE OP_RETURNoutputs, we fall back to the script of any input's previous output to query history. The only case still skipped is a coinbase with all unindexed outputs, since coinbases have no parent to fall back on.Changelog notice
Checklists
All Submissions: