[high] fix: [btc_steroids] filter output transactions on their own value field - #888
Open
elhoim wants to merge 1 commit into
Open
[high] fix: [btc_steroids] filter output transactions on their own value field#888elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
The zero-value filter over transactions["out"] read tx["prev_out"]["value"], but out entries never carry a prev_out key (that field belongs to the "inputs" entries handled earlier in the same function). The KeyError was silently caught and prev_out set to None, so the "prev_out != 0" guard was always true and the filter never excluded zero-value outputs, letting spurious zero-value lines through the enriched btc_steroids report. Verified with flake8 (clean) and the full pytest suite: 161 passed, 4 skipped, 5 subtests passed, against a live modules server on port 6779. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
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.
BLUF —
btc_steroidsreadsprev_outon output entries, so its zero-value filter never excludes anything.btc_steroids.pyreadstx["prev_out"]["value"], butprev_outexists only on input entries, so the lookup always raisesKeyErrorand the zero-value filter never excludes anything.tx["value"], the field actually present onoutentries and already used to compute the displayed value.OP_RETURNand dust outputs cluttering the enrichment result.In
btc_steroids.py, the loop over output transactions readstx["prev_out"]["value"]:Entries in
transactions["out"]never have aprev_outkey — that field belongs to the input entries handled in the loop above (transactions["inputs"]). So the lookup always raisesKeyError,prev_outis always set toNone, andprev_out != 0is alwaysTrue. The zero-value filter therefore never filters anything.Impact: an analyst enriching a bitcoin address/transaction via the
btc_steroidsexpansion module gets zero-value outputs (e.g. OP_RETURN or dust outputs withvalue == 0) listed alongside real payments, cluttering the enrichment result with entries the filter was meant to exclude.Fix: read
tx["value"]directly, which is the field actually present onoutentries (and is already the field used a few lines below to compute and print the displayed value), so the zero-value filter now works as intended.No behaviour change beyond restoring the intended filtering (fewer, correctly-filtered lines in output; no API or module contract change).
Verification
flake8on the changed file: clean, no output.161 passed, 4 skipped, 5 subtests passed in 32.77s.Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code