2017-09-12 12:02:30 -04:00
|
|
|
package address
|
|
|
|
|
|
|
|
import (
|
2019-04-07 00:29:12 -04:00
|
|
|
"github.com/lbryio/lbry.go/extras/errors"
|
2018-02-15 14:51:51 -05:00
|
|
|
"github.com/lbryio/lbryschema.go/address/base58"
|
2017-09-12 12:02:30 -04:00
|
|
|
)
|
|
|
|
|
2018-02-15 14:51:51 -05:00
|
|
|
func DecodeAddress(address string, blockchainName string) ([addressLength]byte, error) {
|
|
|
|
decoded, err := base58.DecodeBase58(address, addressLength)
|
2017-09-12 12:02:30 -04:00
|
|
|
if err != nil {
|
2019-04-07 00:29:12 -04:00
|
|
|
return [addressLength]byte{}, errors.Err("failed to decode")
|
2017-09-12 12:02:30 -04:00
|
|
|
}
|
2018-02-15 14:51:51 -05:00
|
|
|
buf := [addressLength]byte{}
|
2017-09-12 12:02:30 -04:00
|
|
|
for i, b := range decoded {
|
|
|
|
buf[i] = b
|
|
|
|
}
|
2017-11-27 10:24:10 -05:00
|
|
|
|
2017-11-20 13:44:19 -05:00
|
|
|
return ValidateAddress(buf, blockchainName)
|
2017-09-12 12:02:30 -04:00
|
|
|
}
|