Compare commits

..

No commits in common. "main" and "v0.0.3" have entirely different histories.
main ... v0.0.3

View File

@ -1,7 +1,6 @@
package address
import (
"bytes"
"crypto/ecdsa"
"crypto/sha256"
"encoding/hex"
@ -78,22 +77,16 @@ func NewFromHex(s string) (Address, error) {
}
func NewFromBase58(s string) (Address, error) {
b, err := base58.Decode(s)
bytes, err := base58.Decode(s)
if err != nil {
return Address{}, err
}
if len(b) != 25 {
return Address{}, fmt.Errorf("tron address is not 25 bytes but %d", len(b))
if len(bytes) != 25 {
return Address{}, fmt.Errorf("tron address is not 25 bytes but %d", len(bytes))
}
hash := SHA256(SHA256(b[:21]))
checksum := hash[:4]
if !bytes.Equal(checksum, b[21:]) {
return Address{}, fmt.Errorf("invalid checksum")
}
return *(*[21]byte)(b[:21]), nil
return *(*[21]byte)(bytes[:21]), nil
}
func NewFromString(s string) (Address, error) {