From 7558397877bd1dee0b4645333420da9738133b6e Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Sat, 24 Aug 2019 21:04:24 -0400 Subject: [PATCH] Add logging to address decode error Add test for real main net address Add name to mainnet chain params --- lbrycrd/address.go | 2 +- lbrycrd/address_test.go | 12 ++++++++++++ lbrycrd/client.go | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lbrycrd/address_test.go diff --git a/lbrycrd/address.go b/lbrycrd/address.go index 0f06e41..90d8916 100644 --- a/lbrycrd/address.go +++ b/lbrycrd/address.go @@ -34,7 +34,7 @@ func DecodeAddress(addr string, defaultNet *chaincfg.Params) (btcutil.Address, e if err == base58.ErrChecksum { return nil, btcutil.ErrChecksumMismatch } - return nil, errors.Err("decoded address is of unknown format") + return nil, errors.Err("decoded address[%s] is of unknown format even with default chainparams[%s]", addr, defaultNet.Name) } switch len(decoded) { diff --git a/lbrycrd/address_test.go b/lbrycrd/address_test.go new file mode 100644 index 0000000..a6648cc --- /dev/null +++ b/lbrycrd/address_test.go @@ -0,0 +1,12 @@ +package lbrycrd + +import "testing" + +func TestDecodeAddress(t *testing.T) { + addr := "bMUxfQVUeDi7ActVeZJZHzHKBceai7kHha" + btcAddr, err := DecodeAddress(addr, &MainNetParams) + if err != nil { + t.Error(err) + } + println(btcAddr.EncodeAddress()) +} diff --git a/lbrycrd/client.go b/lbrycrd/client.go index 1d77c21..1d343e4 100644 --- a/lbrycrd/client.go +++ b/lbrycrd/client.go @@ -30,6 +30,7 @@ var MainNetParams = chaincfg.Params{ PrivateKeyID: 0x1c, Bech32HRPSegwit: "not-used", // we don't have this (yet) GenesisHash: &GenesisHash, + Name: "mainnet", } func init() {