Skip to content

fix: use btcutil.DecodeAddress for Bitcoin address validation#129

Open
vwinee21 wants to merge 1 commit into
buildonspark:mainfrom
vwinee21:fix/btc-address-validation-use-btcutil
Open

fix: use btcutil.DecodeAddress for Bitcoin address validation#129
vwinee21 wants to merge 1 commit into
buildonspark:mainfrom
vwinee21:fix/btc-address-validation-use-btcutil

Conversation

@vwinee21

Copy link
Copy Markdown

Summary

Replace fragile prefix matching in IsBitcoinAddressForNetwork with proper btcutil.DecodeAddress validation which includes checksum verification.

The previous implementation used simple string prefix matching which could pass invalid addresses (e.g. an address starting with 'bc1' but with invalid checksum). btcutil.DecodeAddress performs full validation against the network's chaincfg.Params.

Network.Params() already exists in the btcnetwork package and returns the correct *chaincfg.Params for each network, making this a clean one-liner replacement.

Resolves the TODO comment in IsBitcoinAddressForNetwork.

Public

Replace prefix-based Bitcoin address checking with btcutil.DecodeAddress for proper validation including checksum verification.

Replace fragile prefix matching with proper btcutil.DecodeAddress
validation which includes checksum verification.

Resolves TODO in IsBitcoinAddressForNetwork.
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.

1 participant