package btc import ( "fmt" "net/http" ) type BitcoinService struct { host string auth string zmqAddress string walletAddress string client *http.Client testNet bool } func NewBitcoinService(host, auth, zmqAddress, walletAddress string) *BitcoinService { bs := BitcoinService{ host: host, auth: auth, zmqAddress: zmqAddress, walletAddress: walletAddress, client: &http.Client{}, } from, err := bs.getAddressGroupings(false) if err != nil { panic(fmt.Errorf("bs.getAddressGroupings %s", err)) } found := false for _, a := range from { if a.address == bs.walletAddress { found = true } } if !found { return nil } return &bs } func (bc *BitcoinService) WithTestnet() *BitcoinService { bc.testNet = true return bc } func (bc *BitcoinService) Explorer(tx string) string { if bc.testNet { return "https://testnet.bitcoinexplorer.org/tx/" + tx } return "https://btcscan.org/tx/" + tx }