Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrivateKeyToBytes ¶
func PrivateKeyToBytes(priv *ecdsa.PrivateKey) []byte
PrivateKeyToBytes returns the 32-byte big-endian representation of the private key's D value, left-padded with zeros if necessary.
func PrivateKeyToHex ¶
func PrivateKeyToHex(priv *ecdsa.PrivateKey) string
PrivateKeyToHex returns the hexadecimal encoding of the private key.
func TronAddressFromPrivate ¶
func TronAddressFromPrivate(priv *ecdsa.PrivateKey) string
TronAddressFromPrivate returns the Base58-encoded Tron address for the provided ECDSA private key. The function computes the uncompressed public key, hashes the X||Y bytes with Keccak-256, takes the last 20 bytes, prefixes with the Tron version byte 0x41, appends a 4-byte checksum (double SHA-256), and encodes the result with Base58.
Types ¶
type ExtKey ¶
ExtKey represents an extended key (private key and chain code) used in BIP32 hierarchical deterministic wallets.
type MnemonicLength ¶
type MnemonicLength int
const ( Mnemonic12Words MnemonicLength = 12 Mnemonic24Words MnemonicLength = 24 )
type TronWallet ¶
type TronWallet struct {
// Mnemonic is the BIP39 mnemonic phrase for the wallet.
Mnemonic string
// Seed is the binary seed derived from the mnemonic (BIP39 seed).
Seed []byte
}
TronWallet represents a TRON wallet with a mnemonic and seed.
func NewWallet ¶
func NewWallet(length ...MnemonicLength) (*TronWallet, error)
NewWallet creates a new TronWallet with a randomly generated mnemonic. The optional length argument can be used to request a 12- or 24-word mnemonic (default is 12 words).
func RestoreWallet ¶
func RestoreWallet(mnemonic string) (*TronWallet, error)
RestoreWallet validates a BIP39 mnemonic string and returns the corresponding TronWallet with the derived seed.
func (*TronWallet) Derive ¶
func (w *TronWallet) Derive(index uint32) (*ecdsa.PrivateKey, error)
Derive returns the ECDSA private key for the given account index following the Tron/BIP44 derivation implemented in deriveTronPrivateKey.