wallet

package
v0.12.199-go Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package wallet manages EVM-compatible wallets for DOSRouter payment. Supports BIP-39 mnemonic generation, key derivation, and balance queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEVMChain

func IsEVMChain(chain string) bool

IsEVMChain returns true if the given chain is EVM-compatible.

func SupportedChains

func SupportedChains() []string

SupportedChains returns the list of supported chain names.

Types

type ChainConfig

type ChainConfig struct {
	Name         string `json:"name"`
	RPCURL       string `json:"rpcUrl"`
	ChainID      int64  `json:"chainId"`
	TokenAddress string `json:"tokenAddress"` // USDC or payment token contract
	TokenSymbol  string `json:"tokenSymbol"`
	Explorer     string `json:"explorer"`
}

Chain configuration

type Wallet

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

Wallet represents an EVM wallet with key material and chain config.

func LoadOrCreate

func LoadOrCreate() (*Wallet, error)

LoadOrCreate loads an existing wallet or creates a new one.

func Recover

func Recover(mnemonic string) (*Wallet, error)

Recover restores a wallet from a mnemonic phrase.

func (*Wallet) Address

func (w *Wallet) Address() string

Address returns the EVM address.

func (*Wallet) Chain

func (w *Wallet) Chain() string

Chain returns the current payment chain name.

func (*Wallet) ChainConfig

func (w *Wallet) ChainConfig() ChainConfig

ChainConfig returns the current chain's configuration.

func (*Wallet) GetBalance

func (w *Wallet) GetBalance() (float64, error)

GetBalance queries the on-chain balance for the wallet's token.

func (*Wallet) IsNew

func (w *Wallet) IsNew() bool

IsNew returns true if this wallet was just created.

func (*Wallet) Mnemonic

func (w *Wallet) Mnemonic() string

Mnemonic returns the mnemonic phrase (empty if loaded from private key).

func (*Wallet) PrivateKeyHex

func (w *Wallet) PrivateKeyHex() string

PrivateKeyHex returns the private key as a hex string.

func (*Wallet) SetChain

func (w *Wallet) SetChain(name string) error

SetChain switches the payment chain.

Jump to

Keyboard shortcuts

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