Documentation
¶
Overview ¶
Package address provides TRON address encoding, decoding, and validation.
Index ¶
- Constants
- type Address
- func BTCECPrivkeyToAddress(p *btcec.PrivateKey) Address
- func BTCECPubkeyToAddress(p *btcec.PublicKey) Address
- func Base58ToAddress(s string) (Address, error)
- func Base64ToAddress(s string) (Address, error)
- func BigToAddress(b *big.Int) Address
- func BytesToAddress(b []byte) Address
- func EthAddressToAddress(ethAddr []byte) (Address, error)
- func HexToAddress(s string) Address
- func PubkeyToAddress(p ecdsa.PublicKey) Address
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 21 // AddressLengthBase58 is the expected length of the address in base58format AddressLengthBase58 = 34 // TronBytePrefix is the hex prefix to address TronBytePrefix = byte(0x41) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address []byte
Address represents the 21 byte address of an Tron account.
func BTCECPrivkeyToAddress ¶ added in v0.24.1
func BTCECPrivkeyToAddress(p *btcec.PrivateKey) Address
BTCECPrivkeyToAddress derives a TRON address from a btcec private key.
func BTCECPubkeyToAddress ¶ added in v0.24.1
BTCECPubkeyToAddress derives a TRON address from a btcec public key.
func Base58ToAddress ¶
Base58ToAddress returns Address with byte values of s.
func Base64ToAddress ¶
Base64ToAddress returns Address with byte values of s.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶ added in v0.25.2
BytesToAddress converts raw bytes to a TRON Address. For 20-byte input, the TRON mainnet prefix (0x41) is prepended. For 21-byte input, the bytes are copied as-is. For any other length, a copy of the input bytes is returned without validation.
func EthAddressToAddress ¶ added in v0.25.2
EthAddressToAddress converts a 20-byte Ethereum address to a 21-byte TRON address. It prepends the TRON mainnet prefix (0x41). Returns an error if the input is not exactly 20 bytes.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func PubkeyToAddress ¶
PubkeyToAddress derives a TRON address from an ECDSA public key.
func (*Address) Scan ¶
Scan implements the database/sql.Scanner interface for reading addresses from database columns.