Repository navigation
Conversation
BIP155 says Tor v2 addresses MUST be ignored on receive. Before this change, readNetAddressV2 still decoded torv2 entries and returned ErrInvalidAddressSize when the address was not 10 bytes long, which made the whole addrv2 message fail to decode, valid addresses included. Handle torv2 the same way as an unknown network ID: read and discard the address and port, and return ErrSkippedNetworkID. This matches Bitcoin Core and rust-bitcoin. Fixes btcsuite#2683
allocz
reviewed
Nov 13, 2026
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.
Change Description
Fixes #2683.
BIP155 says Tor v2 addresses MUST be ignored on receive.
readNetAddressV2still decoded torv2 entries and returned
ErrInvalidAddressSizewhen theaddress was not 10 bytes long, so the whole
addrv2message was rejected,including any valid addresses in it.
This change handles torv2 the same way as an unknown network ID: the address
and port are read and discarded, and
ErrSkippedNetworkIDis returned. Sizesabove
maxAddrV2Sizeare still rejected. This matches Bitcoin Core andrust-bitcoin.
Steps to Test
cd wire
go test -run 'TestReadNetAddressV2|TestAddrV2Decode' -v .
The two existing torv2 cases in
TestReadNetAddressV2now expectErrSkippedNetworkID, for both a wrong-size and a correct-size address.The wrong-size case fails with
invalid address sizewithout this change.Pull Request Checklist
Testing
Code Style and Documentation