lbry.go/schema/address/decode.go

20 lines
485 B
Go
Raw Normal View History

2017-09-12 18:02:30 +02:00
package address
import (
2020-09-01 19:58:08 +02:00
"github.com/lbryio/lbry.go/v2/extras/errors"
2020-09-01 19:45:55 +02:00
"github.com/lbryio/lbry.go/v2/schema/address/base58"
2017-09-12 18:02:30 +02:00
)
2018-02-15 20:51:51 +01:00
func DecodeAddress(address string, blockchainName string) ([addressLength]byte, error) {
decoded, err := base58.DecodeBase58(address, addressLength)
2017-09-12 18:02:30 +02:00
if err != nil {
return [addressLength]byte{}, errors.Err("failed to decode")
2017-09-12 18:02:30 +02:00
}
2018-02-15 20:51:51 +01:00
buf := [addressLength]byte{}
2017-09-12 18:02:30 +02:00
for i, b := range decoded {
buf[i] = b
}
return ValidateAddress(buf, blockchainName)
2017-09-12 18:02:30 +02:00
}