fix(crypto): tighten XRP regex to reduce false positives (#58)#59
Merged
German7463 merged 2 commits intomasterfrom Apr 13, 2026
Merged
fix(crypto): tighten XRP regex to reduce false positives (#58)#59German7463 merged 2 commits intomasterfrom
German7463 merged 2 commits intomasterfrom
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.
Summary
Fixes #58 — XRP wallet addresses were generating false positives for common English words starting with
r(e.g.rrocchiapreziosissimosangue,rivheavenskingdomchristianschoo).isvalid()) or other crypto patternsRoot Cause
The old XRP regex used Ripple's own base58 alphabet (
rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz), which contains nearly every Latin character. Any long word starting withrwould match the regex pattern before ever reaching checksum validation.Changes
restalker/restalker.pyOld regex:
New regex:
The fix switches to the standard Bitcoin base58 charset for the regex pre-filter — which excludes
0,O,I, andl— dramatically reducing false positive surface area. The Ripple-specific alphabet decoding with checksum verification is still performed inXRP_Wallet.isvalid(), so valid address validation is completely unchanged.The
X-prefix (X-addresses) is removed from the regex scope per the original format's limited adoption; classicr-prefix addresses are the standard.tests/test_restalker.pyAdded 4 new test functions:
test_xrp_false_positives_issue_58test_xrp_valid_addresses_still_detectedtest_btc_false_positive_checktest_crypto_regex_no_word_false_positivesResults
False positives correctly rejected:
rrocchiapreziosissimosanguerivheavenskingdomchristianschoorawdedziwnyjesttenswiatSP4ESFr1962KLLLLAAAAAAAAAAAAAAAAUUUDValid XRP addresses still detected:
rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLhrMJctfTc2XGeNyiATi4aE4UHLDpE6WBZaWrJ1ytK9Ya6HPmyozCogGtF79nqXjqSZRkEBTC: The BTC false positive
14uBSjQBjgHaoUwXW4nSxzxJZ2e23iGQLimatches the regex but is correctly rejected byBTC_Wallet.isvalid()checksum validation — no regex change needed for BTC.Testing
pytest tests/test_restalker.py::test_xrp_false_positives_issue_58 \ tests/test_restalker.py::test_xrp_valid_addresses_still_detected \ tests/test_restalker.py::test_btc_false_positive_check \ tests/test_restalker.py::test_crypto_regex_no_word_false_positives -vAll 4 new tests pass. Existing crypto detection tests (
test_crypto_detection,test_btc_wallet_validation) continue to pass with no regressions.