lbry.go/schema/address/decode.go
2020-09-01 13:30:36 -04:00

19 lines
478 B
Go

package address
import (
"github.com/lbryio/lbry.go/extras/errors"
"github.com/lbryio/lbryschema.go/address/base58"
)
func DecodeAddress(address string, blockchainName string) ([addressLength]byte, error) {
decoded, err := base58.DecodeBase58(address, addressLength)
if err != nil {
return [addressLength]byte{}, errors.Err("failed to decode")
}
buf := [addressLength]byte{}
for i, b := range decoded {
buf[i] = b
}
return ValidateAddress(buf, blockchainName)
}