tronkey

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// HashLength is the expected length of the hash
	HashLength = 32
	// AddressLengthBase58 is the expected length of the address in base58format
	AddressLengthBase58 = 34

	// TronBytePrefix is the hex prefix to address
	TronBytePrefix = byte(prefixMainnet)
	// Tron address should have 21 bytes (20 bytes + 1 byte prefix)
	AddressLength = 21
)

Variables

This section is empty.

Functions

func BytesToHexString

func BytesToHexString(bytes []byte) string

BytesToHexString encodes bytes as a hex string.

func Decode

func Decode(input string) ([]byte, error)

func DecodeCheck

func DecodeCheck(input string) ([]byte, error)

func Encode

func Encode(input []byte) string

func EncodeCheck

func EncodeCheck(input []byte) string

func FromHex

func FromHex(s string) ([]byte, error)

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Has0xPrefix

func Has0xPrefix(str string) bool

Has0xPrefix validates str begins with '0x' or '0X'.

func HexToBytes

func HexToBytes(str string) ([]byte, error)

HexToBytes returns the bytes represented by the hexadecimal string str.

Types

type Address

type Address [AddressLength]byte

Address represents the 21 byte address of an Tron account.

func Base58ToAddress

func Base58ToAddress(s string) (Address, error)

Base58ToAddress returns Address with byte values of s.

func HexToAddress

func HexToAddress(s string) (Address, error)

HexToAddress returns Address with byte values of s.

func PubkeyToAddress

func PubkeyToAddress(p ecdsa.PublicKey) Address

PubkeyToAddress returns address from ecdsa public key

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes get bytes from address

func (Address) Hex

func (a Address) Hex() string

Hex get bytes from address in string

func (Address) String

func (a Address) String() string

String implements fmt.Stringer. Returns the address as a base58 encoded string.

type Key

type Key struct {
	// contains filtered or unexported fields
}

func FromEncryptedJSON

func FromEncryptedJSON(keyJSON []byte, password string) (Key, error)

FromEncryptedJSON gets key from json and password

func KeyFor

func KeyFor(raw internal.Raw) Key

Key generates a public-private key pair from the raw private key

func MustNewInsecure

func MustNewInsecure(reader io.Reader) Key

MustNewInsecure return Key if no error This insecure function is used for testing purposes only

func New

func New() (Key, error)

func (Key) Base58Address

func (key Key) Base58Address() string

Base58Address returns the Tron address in Base58 format with checksum

func (Key) ID

func (key Key) ID() string

func (Key) PublicKeyStr

func (key Key) PublicKeyStr() string

PublicKeyStr returns the public key as a hexadecimal string

func (Key) Raw

func (key Key) Raw() internal.Raw

func (Key) Sign

func (key Key) Sign(msg []byte) ([]byte, error)

Sign is used to sign a message

func (Key) ToEncryptedJSON

func (key Key) ToEncryptedJSON(password string, scryptParams commonkeystore.ScryptParams) (export []byte, err error)

ToEncryptedJSON returns encrypted JSON representing key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL