btcd/btcutil/net_android.go
Calvin Kim 153bf6d828 btcutil: use anet instead of net for android builds
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.
2026-05-14 16:16:14 -07:00

25 lines
652 B
Go

// Copyright (c) 2025 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
//go:build android
// +build android
package btcutil
import (
"net"
"github.com/kcalvinalvin/anet"
)
// InterfaceAddrs returns a list of the system's network interface addresses.
// We specifically wrap anet.InterfaceAddrs as the net pakcage has been broken
// since android 11.
//
// The relevant github issue link is:
// https://github.com/golang/go/issues/40569.
// When the issue is later resolved, we should remove it.
func InterfaceAddrs() ([]net.Addr, error) {
return anet.InterfaceAddrs()
}