wallet

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientFunds = errors.New("insufficient funds")
	ErrNoUTXOs           = errors.New("no UTXOs available")
	ErrInvalidAddress    = errors.New("invalid address")
)

Functions

This section is empty.

Types

type TransferInput

type TransferInput struct {
	UTXOID  ids.ID
	AssetID ids.ID
	Amount  uint64
}

TransferInput represents an input to a transfer transaction

type TransferOutput

type TransferOutput struct {
	AssetID   ids.ID
	Amount    uint64
	Recipient ids.ShortID
	Locktime  uint64
}

TransferOutput represents an output from a transfer transaction

type TransferTx

type TransferTx struct {
	NetworkID uint32
	ChainID   ids.ID
	Inputs    []TransferInput
	Outputs   []TransferOutput
	Memo      []byte
}

TransferTx represents a transfer transaction

type UTXO

type UTXO struct {
	ID       ids.ID
	AssetID  ids.ID
	Amount   uint64
	Owner    ids.ShortID
	Locktime uint64
}

UTXO represents an unspent transaction output

type Wallet

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

Wallet manages keys and transactions for personal usage

func New

func New(networkID uint32, chainID ids.ID) *Wallet

New creates a new wallet instance

func (*Wallet) AddUTXO

func (w *Wallet) AddUTXO(utxo *UTXO)

AddUTXO adds a UTXO to the wallet

func (*Wallet) CreateTransferTx

func (w *Wallet) CreateTransferTx(
	to ids.ShortID,
	assetID ids.ID,
	amount uint64,
	memo []byte,
) (*TransferTx, error)

CreateTransferTx creates a transfer transaction

func (*Wallet) GenerateKey

func (w *Wallet) GenerateKey() (ids.ShortID, error)

GenerateKey generates a new key and adds it to the wallet

func (*Wallet) GetAddress

func (w *Wallet) GetAddress() (ids.ShortID, error)

GetAddress returns a wallet address

func (*Wallet) GetAllAddresses

func (w *Wallet) GetAllAddresses() []ids.ShortID

GetAllAddresses returns all wallet addresses

func (*Wallet) GetBLSKey

func (w *Wallet) GetBLSKey() (*bls.SecretKey, error)

GetBLSKey returns the BLS key for validator operations

func (*Wallet) GetBalance

func (w *Wallet) GetBalance(assetID ids.ID) uint64

GetBalance returns the balance for a specific asset

func (*Wallet) GetUTXOs

func (w *Wallet) GetUTXOs(assetID ids.ID, amount uint64) ([]*UTXO, uint64, error)

GetUTXOs returns UTXOs for spending

func (*Wallet) ImportKey

func (w *Wallet) ImportKey(privateKey crypto.PrivateKey) (ids.ShortID, error)

ImportKey imports a private key into the wallet

func (*Wallet) RemoveUTXO

func (w *Wallet) RemoveUTXO(utxoID ids.ID)

RemoveUTXO removes a UTXO from the wallet

func (*Wallet) SetBLSKey

func (w *Wallet) SetBLSKey(key *bls.SecretKey)

SetBLSKey sets the BLS key for validator operations

func (*Wallet) Sign

func (w *Wallet) Sign(ctx context.Context, tx chain.Transaction) error

Sign signs a transaction with the wallet's keys

Jump to

Keyboard shortcuts

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