Skip to content

btcutil, main: fix android builds#2461

Open
kcalvinalvin wants to merge 4 commits intobtcsuite:masterfrom
kcalvinalvin:2025-11-12-fix-android-builds
Open

btcutil, main: fix android builds#2461
kcalvinalvin wants to merge 4 commits intobtcsuite:masterfrom
kcalvinalvin:2025-11-12-fix-android-builds

Conversation

@kcalvinalvin
Copy link
Copy Markdown
Collaborator

Change Description

For android since version 11, net.InterfaceAddrs() has been broken.
This means that while btcd will build fine on android, it won't run as the logs show below:

[I] u0_a306@localhost ~/btcd (master)> ./btcd --prune=1536
2025-11-12 18:15:09.771 [INF] BTCD: Version 0.25.0-beta
2025-11-12 18:15:09.771 [INF] BTCD: Loading block database from '/data/data/com.termux/files/home/.btcd/data/mainnet/blocks_ffldb'
2025-11-12 18:15:09.779 [INF] BTCD: Block database loaded
2025-11-12 18:15:09.780 [WRN] AMGR: Skipping bound address 0.0.0.0:8333: route ip+net: netlinkrib: permission denied
2025-11-12 18:15:09.780 [WRN] AMGR: Skipping bound address [::]:8333: route ip+net: netlinkrib: permission denied
2025-11-12 18:15:09.799 [INF] INDX: Committed filter index is enabled
2025-11-12 18:15:09.799 [INF] BTCD: Prune set to 1536 MiB
2025-11-12 18:15:09.799 [INF] CHAN: Pre-alloacting for 251 MiB
2025-11-12 18:15:09.867 [INF] INDX: Catching up indexes from height -1 to 0
2025-11-12 18:15:09.867 [INF] INDX: Indexes caught up to height 0
2025-11-12 18:15:09.867 [INF] CHAN: Chain state (height 0, hash 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f, totaltx 1, work [4295032833](tel:4295032833))
2025-11-12 18:15:09.867 [INF] RPCS: Generating TLS certificates...
2025-11-12 18:15:09.874 [ERR] BTCD: Unable to start server on [:8333]: route ip+net: netlinkrib: permission denied
2025-11-12 18:15:09.874 [INF] BTCD: Gracefully shutting down the database...
2025-11-12 18:15:09.882 [INF] BTCD: Shutdown complete

So if we're building on Android, we use the alternate net library called anet.
I specifically use my own fork to utilize wlynxg/anet#9 as the master branch requires an extra build flag.

Steps to Test

1: Download Termux on an Android device.
2: Clone btcd.
3: Build.
4: Run to see if it works.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

Golang's net package has been broken for android since android 11
and the node will not be able to call net.InterfaceAddr() without
root.

For android builds, we use anet so that the btcd node can be used
without root.
We update go.mod and go.sum to point to the local btcutil library.

This commit should be updated later on so that we do it right.
We use this as the net.InterfaceAddr is broken from android 11.
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 19308219956

Details

  • 2 of 3 (66.67%) changed or added relevant lines in 3 files are covered.
  • 13 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.04%) to 54.917%

Changes Missing Coverage Covered Lines Changed/Added Lines %
server.go 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
btcutil/bech32/bech32.go 1 99.61%
mempool/mempool.go 1 66.56%
btcutil/bloom/filter.go 2 96.84%
btcutil/gcs/gcs.go 4 80.95%
rpcclient/infrastructure.go 5 47.7%
Totals Coverage Status
Change from base Build 19121431262: -0.04%
Covered Lines: 31158
Relevant Lines: 56737

💛 - Coveralls

@saubyk saubyk added android Issues related to Android platform build labels Nov 12, 2025
Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎗️


go 1.23.2

replace github.com/btcsuite/btcd/btcutil => ./btcutil
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

@Roasbeef Roasbeef added this to the v0.25.1 milestone Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android Issues related to Android platform build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants