account

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: LGPL-3.0 Imports: 11 Imported by: 14

Documentation

Overview

Package account provides TRON account creation, import, and export operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewLocalAccount

func CreateNewLocalAccount(candidate *Creation) error

CreateNewLocalAccount creates a new account in the local keystore from the given Creation params.

func ExportKeystore

func ExportKeystore(address, path, passphrase string) (string, error)

ExportKeystore writes the encrypted keystore JSON for the given address to a file at path.

func ExportPrivateKey

func ExportPrivateKey(address, passphrase string) error

ExportPrivateKey prints the hex-encoded private key for the given address to stdout.

func ImportFromPrivateKey

func ImportFromPrivateKey(privateKey, name, passphrase string) (string, error)

ImportFromPrivateKey imports an ECDSA private key (hex string) into the local keystore under the given name.

func ImportKeyStore

func ImportKeyStore(keyPath, name, passphrase string) (string, error)

ImportKeyStore imports an encrypted keystore JSON file into the local account store.

func IsValidPassphrase

func IsValidPassphrase(pass string) bool

IsValidPassphrase is a placeholder that currently always returns true. TODO: implement actual strength validation.

func New

func New() string

New returns the default name for a new account.

func RemoveAccount

func RemoveAccount(name string) error

RemoveAccount deletes the named account and its keystore files from the local store.

Types

type Account

type Account struct {
	Address                 string             `json:"address"`
	Type                    string             `json:"type"`
	Name                    string             `json:"name"`
	ID                      string             `json:"id"`
	Balance                 int64              `json:"balance"`
	Allowance               int64              `json:"allowance"`
	LastWithdraw            int64              `json:"lastWithdraw"`
	IsWitness               bool               `json:"isWitness"`
	IsElected               bool               `json:"isElected"`
	Assets                  map[string]int64   `json:"assetList"`
	TronPower               int64              `json:"tronPower"`
	TronPowerUsed           int64              `json:"tronPowerUsed"`
	FrozenBalance           int64              `json:"frozenBalance"`
	FrozenResources         []FrozenResource   `json:"frozenList"`
	FrozenBalanceV2         int64              `json:"frozenBalanceV2"`
	FrozenResourcesV2       []FrozenResource   `json:"frozenListV2"`
	UnfrozenResource        []UnfrozenResource `json:"unfrozenList"`
	Votes                   map[string]int64   `json:"voteList"`
	BWTotal                 int64              `json:"bandwidthTotal"`
	BWUsed                  int64              `json:"bandwidthUsed"`
	EnergyTotal             int64              `json:"energyTotal"`
	EnergyUsed              int64              `json:"energyUsed"`
	Rewards                 int64              `json:"rewards"`
	WithdrawableBalance     int64              `json:"withdrawableBalance"`
	UnfreezeLeft            int64              `json:"countUnfreezeLeft"`
	MaxCanDelegateBandwidth int64              `json:"maxCanDelegateBandwidth"`
	MaxCanDelegateEnergy    int64              `json:"maxCanDelegateEnergy"`
}

Account holds a detailed view of a TRON account including balances, resources, and votes.

type Creation

type Creation struct {
	Name               string
	Passphrase         string
	Mnemonic           string
	MnemonicPassphrase string
	HdAccountNumber    *uint32
	HdIndexNumber      *uint32
}

Creation holds the parameters needed to create a new local TRON account.

type FrozenResource

type FrozenResource struct {
	Type       core.ResourceCode
	Amount     int64
	DelegateTo string
	Expire     int64
}

FrozenResource represents a frozen resource (bandwidth or energy) on a TRON account.

type UnfrozenResource

type UnfrozenResource struct {
	Type   core.ResourceCode
	Amount int64
	Expire int64
}

UnfrozenResource represents a pending unfreeze operation on a TRON account.

Jump to

Keyboard shortcuts

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