Add logging to address decode error

Add test for real main net address
Add name to mainnet chain params
This commit is contained in:
Mark Beamer Jr 2019-08-24 21:04:24 -04:00
parent fb7d045753
commit 7558397877
No known key found for this signature in database
GPG key ID: 1C314FB89AD76973
3 changed files with 14 additions and 1 deletions

View file

@ -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) {

12
lbrycrd/address_test.go Normal file
View file

@ -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())
}

View file

@ -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() {