wallet

package
v1.42.4 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 17 Imported by: 2 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoKeyGen = errors.New("wallet: no key generator registered for chain type")

ErrNoKeyGen is returned when CreateAccount is called for a chain type whose key-generator hasn't been registered.

View Source
var ErrorInvalidTypeSpecified = errors.New("Invalid account type specified.")
View Source
var ErrorNameCollision = errors.New("Account with name already exists.")
View Source
var ErrorNoEncryptedKeyFound = errors.New("No encrypted key found.")
View Source
var ErrorNoPrivateKeySet = errors.New("No private key is set.")
View Source
var ErrorNoSaltSetError = errors.New("No salt is set.")

Functions

func Fake

func Fake(db *datastore.Datastore) (*Wallet, *Account, string)

func Query

func RegisterKeyGen added in v1.40.0

func RegisterKeyGen(typ blockchains.Type, fn KeyGen)

RegisterKeyGen wires a key generator for a chain type. Later registrations override earlier ones; callers should register once at init time.

Types

type Account

type Account struct {
	Encrypted string `json:"encrypted"`
	Salt      string `json:"salt"`

	Name       string `json:"name"`
	PrivateKey string `json:"-" datastore:"-"`
	PublicKey  string `json:"-"`
	Address    string `json:"address,omitempty"`

	// Can this account be withdrawn from?  This is on the org.
	Withdrawable bool             `json:"-"`
	Deleted      bool             `json:"-"`
	Type         blockchains.Type `json:"type"`

	CreatedAt time.Time `json:"createdAt,omitempty"`

	// Ignore these, this is deprecated
	TestNetAddress string `json:"-"`
	AddressBackup  string `json:"-"`
}

func (*Account) Decrypt

func (a *Account) Decrypt(withPassword []byte) error

Decrypt the Account's Private Key

func (*Account) Delete

func (a *Account) Delete()

func (*Account) Encrypt

func (a *Account) Encrypt(withPassword []byte) error

Encrypt the Account's Private Key

type KeyGen added in v1.40.0

type KeyGen func(typ blockchains.Type) (priv, pub, address string, err error)

KeyGen returns (privateKeyHex, publicKeyHex, address) for a given chain type. Implementations register themselves via RegisterKeyGen. Bitcoin and Ethereum are wired in-tree (keygen_bitcoin.go / keygen_ethereum.go) because they only need luxfi/crypto primitives; the thirdparty/ethereum sub-module layers payment (JSON-RPC) support on top via RegisterPayment.

type Wallet

type Wallet struct {
	mixin.Model[Wallet]

	Accounts []Account `json:"accounts,omitempty"`
}

func New

func New(db *datastore.Datastore) *Wallet

func (*Wallet) CreateAccount

func (w *Wallet) CreateAccount(name string, typ blockchains.Type, withPassword []byte) (*Account, error)

Create a new Account, saves if wallet is created. Key generation is dispatched to a per-chain registry populated by importing the relevant blockchain package (e.g. thirdparty/bitcoin for BTC, thirdparty/ethereum for EVM). CreateAccount returns ErrNoKeyGen for chain types whose generator hasn't been registered.

func (*Wallet) Defaults

func (w *Wallet) Defaults()

func (*Wallet) GetAccountByName

func (w *Wallet) GetAccountByName(name string) (*Account, bool)

type WalletHolder

type WalletHolder struct {
	WalletId string  `json:"walletId"`
	Wallet   *Wallet `json:"wallet,omitempty" datastore:"-"`
}

func (*WalletHolder) GetOrCreateWallet

func (w *WalletHolder) GetOrCreateWallet(db *datastore.Datastore) (*Wallet, error)

func (*WalletHolder) LoadWallet

func (w *WalletHolder) LoadWallet(db *datastore.Datastore) error

Jump to

Keyboard shortcuts

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