btcutil: vendor anet instead of depending on a personal fork - #2554
Open
Roasbeef wants to merge 1 commit into
Open
btcutil: vendor anet instead of depending on a personal fork#2554Roasbeef wants to merge 1 commit into
Roasbeef wants to merge 1 commit into
Conversation
In this commit, we vendor the Android networking shim that backs InterfaceAddrs on android into the btcutil module, rather than importing it from github.com/kcalvinalvin/anet. The shim works around golang/go#40569, where net.InterfaceAddrs fails with "route ip+net: netlinkrib: permission denied" on Android 11 and later because of the tightened restrictions on NETLINK sockets. btcutil only ever calls anet.InterfaceAddrs, wired in from net_android.go under the android build tag. The motivation is dependency hygiene. The previous import pointed at a fork hosted under an individual contributor's account, which is not a home we want a release dependency to live in. By copying the source into internal/anet we drop the external module entirely: the package is now unimportable from outside btcutil, and go.mod no longer references the fork. The source originates from github.com/wlynxg/anet, and its BSD 3-Clause LICENSE travels with it. Unlike upstream, this copy does not reach into the standard library's net package via //go:linkname; it carries its own ipv6ZoneCache, so no -ldflags "-checklinkname=0" linker flag is needed to build it. When golang/go#40569 is resolved upstream, both this package and the net_android.go shim can be removed.
Coverage Report for CI Build 27794794665Coverage decreased (-0.004%) to 51.803%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
allocz
approved these changes
Jun 19, 2026
allocz
left a comment
There was a problem hiding this comment.
Compared the diff against https://github.com/kcalvinalvin/anet, LGTM.
kcalvinalvin
approved these changes
Jun 24, 2026
kcalvinalvin
left a comment
Collaborator
There was a problem hiding this comment.
LGTM ce4e0f5
Verified that the contents of anet/ are the same.
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.
In this PR, we vendor the Android networking shim that backs
InterfaceAddrson android into thebtcutilmodule, so we no longer pull it fromgithub.qkg1.top/kcalvinalvin/anet. The shim exists to work around golang/go#40569, wherenet.InterfaceAddrsfails withroute ip+net: netlinkrib: permission deniedon Android 11 and later because of the tightened restrictions onNETLINKsockets.btcutilonly ever callsanet.InterfaceAddrs, wired in fromnet_android.gounder theandroidbuild tag.The motivation here is dependency hygiene. The old import pointed at a fork hosted under an individual contributor's account, which isn't a home we want a release dependency to live in. By copying the source into
btcutil/internal/anetwe drop the external module entirely: the package is now unimportable from outsidebtcutil, andbtcutil/go.modno longer references the fork.What's in the vendored copy
The source originates from
github.com/wlynxg/anet, and its BSD 3-ClauseLICENSEtravels with it for attribution. Themobile/demo subpackage from upstream is dropped since we don't need it.One nice property of this particular fork: unlike upstream, it doesn't reach into the standard library's
netpackage via//go:linkname. It carries its ownipv6ZoneCacheinstead, so there's no need for the-ldflags "-checklinkname=0"linker flag that upstream's README calls for on Go 1.23+. I swapped the upstream README for a short provenance note so that misleading build instruction doesn't linger.Scope
The real change lives in the
btcutilmodule, which is the only consumer ofanet. The root andpsbtmodules still carryanetas a transitive// indirectrequirement because they depend on the publishedbtcutil/v2 v2.0.0(there's noreplaceorgo.workwiring them to the local tree). Those entries will fall away naturally on the nextbtcutiltag that ships this commit.Verified that
internal/anetandbtcutilboth build forGOOS=android GOARCH=arm64, the normal host build andgo vetpass, and nokcalvinalvinreferences remain in the module.