Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
var ErrorInvalidTypeSpecified = errors.New("Invalid account type specified.")
var ErrorNameCollision = errors.New("Account with name already exists.")
var ErrorNoEncryptedKeyFound = errors.New("No encrypted key found.")
var ErrorNoPrivateKeySet = errors.New("No private key is set.")
var ErrorNoSaltSetError = errors.New("No salt is set.")
Functions ¶
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:"-"`
}
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 ¶
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.
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