Documentation ¶
Overview ¶
Copyright (c) 2018-2020 The qitmeer developers Copyright (c) 2013-2017 The btcsuite developers Copyright (c) 2015-2016 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- func Create(db walletdb.DB, pubPass, privPass, seed []byte, params *chaincfg.Params, ...) error
- func DecodeToken(bytes []byte) (*json.TokenState, error)
- func EncodeToken(state json.TokenState) []byte
- func IsValidIDType(id interface{}) bool
- func NewHtpc(cfg *config.Config) (*httpConfig, error)
- func NewHtpcByCfg(cfg *client.Config) (*httpConfig, error)
- func NewNotificationRpc(cfg *config.Config, handlers client.NotificationHandlers) (*client.Client, error)
- func TxEncode(version uint32, lockTime uint32, timestamp *time.Time, inputs []Input, ...) (string, error)
- type API
- func (api *API) CreateAccount(name string) error
- func (api *API) CreateAddress(accountName string) (string, error)
- func (api *API) DumpPrivKey(addrStr string) (string, error)
- func (api *API) GetAccountByAddress(addrStr string) (string, error)
- func (api *API) GetAccountsAndBalance(coin types.CoinID) (map[string]*Value, error)
- func (api *API) GetAddressesByAccount(accountName string) ([]string, error)
- func (api *API) GetBalanceByAccount(name string, coin types.CoinID) (*Value, error)
- func (api *API) GetBalanceByAddr(addrStr string, coin types.CoinID) (map[string]Value, error)
- func (api *API) GetBillByAddr(addr string, filter int, page int, pageSize int) (*clijson.PagedBillResult, error)
- func (api *API) GetTx(txID string) (*corejson.TxRawResult, error)
- func (api *API) GetTxListByAddr(addr string, sType int, page int, pageSize int) (*clijson.PageTxRawResult, error)
- func (api *API) GetUTxo(addr string, coin types.CoinID) ([]wtxmgr.UTxo, error)
- func (api *API) ImportPrivKey(accountName string, key string) error
- func (api *API) ImportWifPrivKey(accountName string, key string) error
- func (api *API) Lock() error
- func (api *API) SendLockedToAddress(addressStr string, amount float64, coin types.CoinID, lockHeight uint64) (string, error)
- func (api *API) SendToAddress(addressStr string, amount float64, coin types.CoinID, byAddress string) (string, error)
- func (api *API) SendToAddressByAccount(accountName string, addressStr string, amount float64, coin types.CoinID, ...) (string, error)
- func (api *API) SendToMany(addAmounts map[string]float64, coin types.CoinID, byAddress string) (string, error)
- func (api *API) SyncStats() (*SyncStats, error)
- func (api *API) Unlock(walletPriPass string, second int64) error
- type AccountAddress
- type AccountAndAddressResult
- type AccountBalanceResult
- type AddrAndAddrTxOutput
- type Amount
- type ApiAmount
- type Balance
- type Input
- type Loader
- func (l *Loader) CreateNewWallet(pubPassphrase, privPassphrase, seed []byte, bday time.Time) (*Wallet, error)
- func (l *Loader) LoadedWallet() (*Wallet, bool)
- func (l *Loader) OpenExistingWallet(pubPassphrase []byte, canConsolePrompt bool) (*Wallet, error)
- func (l *Loader) OpenWallet() (*Wallet, error)
- func (l *Loader) RunAfterLoad(fn func(*Wallet))
- func (l *Loader) UnloadWallet() error
- func (l *Loader) WalletExists() (bool, error)
- type QitmeerToken
- type RPCError
- type RPCErrorCode
- type Request
- type Response
- type SyncStats
- type TxOutput
- type Value
- type Wallet
- func (w *Wallet) AccountAddresses(account uint32) (addrs []types.Address, err error)
- func (w *Wallet) AccountBalances(scope waddrmgr.KeyScope) ([]AccountBalanceResult, error)
- func (w *Wallet) AccountEVMAddresses(account uint32) (addrs []common2.Address, err error)
- func (w *Wallet) AccountName(scope waddrmgr.KeyScope, accountNumber uint32) (string, error)
- func (w *Wallet) AccountNumber(scope waddrmgr.KeyScope, accountName string) (uint32, error)
- func (w *Wallet) AccountOfAddress(a types.Address) (uint32, error)
- func (w *Wallet) ChainParams() *chaincfg.Params
- func (w *Wallet) ClearTxData() error
- func (w *Wallet) CoinID(coin types.CoinID) (types.CoinID, error)
- func (w *Wallet) Database() walletdb.DB
- func (w *Wallet) DumpWIFPrivateKey(addr types.Address) (string, error)
- func (w *Wallet) EVMToUTXO(amounts map[string]types.Amount, account int64, feeSatPerKb int64, ...) (string, error)
- func (w *Wallet) GetAccountAddress(scope waddrmgr.KeyScope) ([]types.Address, error)
- func (w *Wallet) GetAccountAndAddress(scope waddrmgr.KeyScope) ([]AccountAndAddressResult, error)
- func (w *Wallet) GetAddress(scope waddrmgr.KeyScope, account int) ([]AccountAndAddressResult, error)
- func (w *Wallet) GetBalance(addr string) (map[types.CoinID]Balance, error)
- func (w *Wallet) GetBalanceByCoin(addr string, coin types.CoinID) (map[string]Value, error)
- func (w *Wallet) GetBillByAddr(addr string, filter int, pageNo int, pageSize int) (*clijson.PagedBillResult, error)
- func (w *Wallet) GetListTxByAddr(addr string, sType int, pageNo int, pageSize int) (*clijson.PageTxRawResult, error)
- func (w *Wallet) GetSyncBlockOrder() uint32
- func (w *Wallet) GetTx(txId string) (corejson.TxRawResult, error)
- func (w *Wallet) GetTxSpendInfo(txId string) ([]*wtxmgr.AddrTxOutput, error)
- func (w *Wallet) GetUTXOByAddress(addrs []types.Address, amount types.Amount) ([]*wtxmgr.AddrTxOutput, int64, error)
- func (w *Wallet) GetUnspentAddrOutput(addr string, coin types.CoinID) ([]*wtxmgr.AddrTxOutput, error)
- func (w *Wallet) GetUnspentUTXO(addr string, coin types.CoinID) ([]wtxmgr.UTxo, error)
- func (w *Wallet) ImportPrivateKey(scope waddrmgr.KeyScope, wif *utils.WIF) (string, error)
- func (w *Wallet) Lock()
- func (w *Wallet) Locked() bool
- func (w *Wallet) NewAddress(scope waddrmgr.KeyScope, account uint32) (types.Address, error)
- func (w *Wallet) NextAccount(scope waddrmgr.KeyScope, name string) (uint32, error)
- func (w *Wallet) OnBlockConnected(hash *hash.Hash, height int64, order int64, t time.Time, ...)
- func (w *Wallet) OnNodeExit(nodeExit *cmds.NodeExitNtfn)
- func (w *Wallet) OnRescanFinish(rescanFinish *cmds.RescanFinishedNtfn)
- func (w *Wallet) OnRescanProgress(rescanPro *cmds.RescanProgressNtfn)
- func (w *Wallet) OnTxAcceptedVerbose(c *client.Client, tx *j.DecodeRawTransactionResult)
- func (w *Wallet) OnTxConfirm(txConfirm *cmds.TxConfirmResult)
- func (w *Wallet) SendOutputs(coin2outputs []*TxOutput, coinId types.CoinID, account int64, satPerKb int64, ...) (*string, error)
- func (w *Wallet) SendPairs(amounts map[string]types.Amount, account int64, feeSatPerKb int64, ...) (string, error)
- func (w *Wallet) SetConfig(cfg *config.Config)
- func (w *Wallet) SetSyncedToNum(order int64) error
- func (w *Wallet) ShuttingDown() bool
- func (w *Wallet) Start()
- func (w *Wallet) Stop()
- func (w *Wallet) UnLockManager(passphrase []byte) error
- func (w *Wallet) Unlock(passphrase []byte, lock <-chan time.Time) error
- func (w *Wallet) UpdateBlock(toOrder uint64) error
- func (w *Wallet) WaitForShutdown()
Constants ¶
const ( // InsecurePubPassphrase is the default outer encryption passphrase used // for public data (everything but private keys). Using a non-default // public passphrase can prevent an attacker without the public // passphrase from discovering all past and future wallet addresses if // they gain access to the wallet database. // // NOTE: at time of writing, public encryption only applies to public // data in the waddrmgr namespace. Transactions are not yet encrypted. InsecurePubPassphrase = "public" ImportTxID = "0000000000000000000000000000000000000000000000000000000000000000" ImportTxIndex = types.SupperPrevOutIndex ImportTxSequence = types.TxTypeCrossChainImport )
const ( PageUseDefault = -1 PageDefaultNo = 1 PageDefaultSize = 10 PageMaxSize = 1000000000 FilterIn = 0 FilterOut = 1 FilterAll = 2 )
const CoinBaseMaturity = 720
Variables ¶
var ( // ErrLoaded describes the error condition of attempting to load or // create a wallet when the loader has already done so. ErrLoaded = errors.New("wallet already loaded") // ErrNotLoaded describes the error condition of attempting to close a // loaded wallet when a wallet has not been loaded. ErrNotLoaded = errors.New("wallet is not loaded") // ErrExists describes the error condition of attempting to create a new // wallet when one exists already. ErrExists = errors.New("wallet already exists") )
Functions ¶
func DecodeToken ¶
func DecodeToken(bytes []byte) (*json.TokenState, error)
func EncodeToken ¶
func EncodeToken(state json.TokenState) []byte
func NewHtpcByCfg ¶
NewHtpcByCfg new httpConfig by cfg
func NewNotificationRpc ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API for wallet
func (*API) CreateAccount ¶
CreateAccount create account
func (*API) CreateAddress ¶
CreateAddress by accountName
func (*API) DumpPrivKey ¶
DumpPrivKey dump a single address private key
dumpPriKey handles a DumpPrivKey request with the private key for a single address, or an appropiate error if the wallet is locked.
func (*API) GetAccountByAddress ¶
GetAccountByAddress get account name
func (*API) GetAccountsAndBalance ¶
GetAccountsAndBalance List all accounts[{account,balance}]
func (*API) GetAddressesByAccount ¶
GetAddressesByAccount by account
func (*API) GetBalanceByAccount ¶
GetBalanceByAccount get account balance
func (*API) GetBalanceByAddr ¶
GetBalanceByAddr get balance by address
func (*API) GetBillByAddr ¶
func (api *API) GetBillByAddr(addr string, filter int, page int, pageSize int) (*clijson.PagedBillResult, error)
GetBillByAddr get bill of payments affecting specific address, one payment could affect ONE address
func (*API) GetTx ¶
func (api *API) GetTx(txID string) (*corejson.TxRawResult, error)
GetTx get transaction by ID
func (*API) GetTxListByAddr ¶
func (api *API) GetTxListByAddr(addr string, sType int, page int, pageSize int) (*clijson.PageTxRawResult, error)
GetTxListByAddr get transactions affecting specific address, one transaction could affect MULTIPLE addresses
func (*API) ImportPrivKey ¶
ImportPrivKey import pri key
func (*API) ImportWifPrivKey ¶
ImportWifPrivKey import a WIF-encoded private key and adding it to an account a WIF-encoded private key and adding it to an account.
func (*API) SendLockedToAddress ¶
func (api *API) SendLockedToAddress(addressStr string, amount float64, coin types.CoinID, lockHeight uint64) (string, error)
SendToAddress handles a sendtoaddress RPC request by creating a new transaction spending unspent transaction outputs for a wallet to another payment address. Leftover inputs not sent to the payment address or a fee for the miner are sent back to a new address in the wallet. Upon success, the TxID for the created transaction is returned.
func (*API) SendToAddress ¶
func (api *API) SendToAddress(addressStr string, amount float64, coin types.CoinID, byAddress string) (string, error)
SendToAddress handles a sendtoaddress RPC request by creating a new transaction spending unspent transaction outputs for a wallet to another payment address. Leftover inputs not sent to the payment address or a fee for the miner are sent back to a new address in the wallet. Upon success, the TxID for the created transaction is returned.
func (*API) SendToAddressByAccount ¶
func (api *API) SendToAddressByAccount(accountName string, addressStr string, amount float64, coin types.CoinID, comment string, commentTo string) (string, error)
SendToAddressByAccount by account
func (*API) SendToMany ¶
type AccountAddress ¶
type AccountAndAddressResult ¶
type AccountAndAddressResult struct { AccountNumber uint32 AccountName string AddrsOutput []AddrAndAddrTxOutput }
type AccountBalanceResult ¶
type AccountBalanceResult struct { AccountNumber uint32 `json:"-"` AccountName string AccountBalanceList []Balance }
AccountBalanceResult is a single result for the Wallet.AccountBalances method.
type AddrAndAddrTxOutput ¶
type AddrAndAddrTxOutput struct { Addr string TxoutputMap map[types.CoinID][]wtxmgr.AddrTxOutput // contains filtered or unexported fields }
func NewAddrAndAddrTxOutput ¶
func NewAddrAndAddrTxOutput() *AddrAndAddrTxOutput
type Balance ¶
type Balance struct { TotalAmount *Amount // 总余额 UnspentAmount *Amount // 可用余额 LockAmount *Amount // 锁定 UnconfirmedAmount *Amount // 待确认 SpendAmount *Amount // 已花费 }
func NewBalance ¶
type Loader ¶
func (*Loader) CreateNewWallet ¶
func (l *Loader) CreateNewWallet(pubPassphrase, privPassphrase, seed []byte, bday time.Time) (*Wallet, error)
CreateNewWallet creates a new wallet using the provided public and private passphrases. The seed is optional. If non-nil, addresses are derived from this seed. If nil, a secure random seed is generated.
func (*Loader) LoadedWallet ¶
LoadedWallet returns the loaded wallet, if any, and a bool for whether the wallet has been loaded or not. If true, the wallet pointer should be safe to dereference.
func (*Loader) OpenExistingWallet ¶
OpenExistingWallet opens the wallet from the loader's wallet database path and the public passphrase. If the loader is being called by a context where standard input prompts may be used during wallet upgrades, setting canConsolePrompt will enables these prompts.
func (*Loader) OpenWallet ¶
func (*Loader) RunAfterLoad ¶
RunAfterLoad adds a function to be executed when the loader creates or opens a wallet. Functions are executed in a single goroutine in the order they are added.
func (*Loader) UnloadWallet ¶
UnloadWallet stops the loaded wallet, if any, and closes the wallet database. This returns ErrNotLoaded if the wallet has not been loaded with CreateNewWallet or LoadExistingWallet. The Loader may be reused if this function returns without error.
func (*Loader) WalletExists ¶
WalletExists returns whether a file exists at the loader's database path. This may return an error for unexpected I/O failures.
type QitmeerToken ¶
type QitmeerToken struct {
// contains filtered or unexported fields
}
func NewQitmeerToken ¶
func NewQitmeerToken(ns walletdb.ReadWriteBucket) *QitmeerToken
func (*QitmeerToken) Add ¶
func (q *QitmeerToken) Add(t json.TokenState)
func (*QitmeerToken) Encode ¶
func (q *QitmeerToken) Encode() []byte
func (*QitmeerToken) GetToken ¶
func (q *QitmeerToken) GetToken(coin types.CoinID) (*json.TokenState, error)
type RPCError ¶
type RPCError struct { Code RPCErrorCode `json:"code,omitempty"` Message string `json:"message,omitempty"` }
RPCError represents an error that is used as a part of a JSON-RPC Response object.
type RPCErrorCode ¶
type RPCErrorCode int
A specific type is used to help ensure the wrong errors aren't used.
type Request ¶
type Request struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params []json.RawMessage `json:"params"` ID interface{} `json:"id"` }
Request json req
type Response ¶
type Response struct { Jsonrpc string `json:"jsonrpc"` Result json.RawMessage `json:"result"` Error *RPCError `json:"error"` ID *interface{} `json:"id"` }
type Wallet ¶
type Wallet struct { Manager *waddrmgr.Manager TxStore *wtxmgr.Store HttpClient *httpConfig UploadRun bool // contains filtered or unexported fields }
func Open ¶
func Open(db walletdb.DB, pubPass []byte, _ *waddrmgr.OpenCallbacks, params *chaincfg.Params, _ uint32, cfg *config.Config) (*Wallet, error)
Open loads an already-created wallet from the passed database and namespaces.
func (*Wallet) AccountAddresses ¶
AccountAddresses returns the addresses for every created address for an account.
func (*Wallet) AccountBalances ¶
func (w *Wallet) AccountBalances(scope waddrmgr.KeyScope) ([]AccountBalanceResult, error)
AccountBalances returns all accounts in the wallet and their balances. Balances are determined by excluding transactions that have not met requiredConfs confirmations.
func (*Wallet) AccountEVMAddresses ¶
AccountEVMAddresses returns the addresses for every created address for an account.
func (*Wallet) AccountName ¶
AccountName returns the name of an account.
func (*Wallet) AccountNumber ¶
AccountNumber returns the account number for an account name under a particular key scope.
func (*Wallet) AccountOfAddress ¶
AccountOfAddress finds the account that an address is associated with.
func (*Wallet) ChainParams ¶
ChainParams returns the network parameters for the blockchain the wallet belongs to.
func (*Wallet) ClearTxData ¶
func (*Wallet) Database ¶
Database returns the underlying walletdb database. This method is provided in order to allow applications wrapping btcwallet to store app-specific data with the wallet's database.
func (*Wallet) DumpWIFPrivateKey ¶
DumpWIFPrivateKey returns the WIF encoded private key for a single wallet address.
func (*Wallet) EVMToUTXO ¶
func (w *Wallet) EVMToUTXO(amounts map[string]types.Amount, account int64, feeSatPerKb int64, lockHeight uint64, byAddress string) (string, error)
EVMToUTXO send the amount to utxo account
func (*Wallet) GetAccountAddress ¶
func (*Wallet) GetAccountAndAddress ¶
func (w *Wallet) GetAccountAndAddress(scope waddrmgr.KeyScope) ([]AccountAndAddressResult, error)
func (*Wallet) GetAddress ¶
func (*Wallet) GetBalance ¶
func (*Wallet) GetBalanceByCoin ¶
func (*Wallet) GetBillByAddr ¶
func (w *Wallet) GetBillByAddr(addr string, filter int, pageNo int, pageSize int) (*clijson.PagedBillResult, error)
request the bill of a specific address, a bill is the log of payments, which are the effects that a transaction makes on a specific address a payment can affect only ONE address
func (*Wallet) GetListTxByAddr ¶
func (w *Wallet) GetListTxByAddr(addr string, sType int, pageNo int, pageSize int) (*clijson.PageTxRawResult, error)
* request all the transactions that affect a specific address, a transaction can have MULTIPLE payments and affect MULTIPLE addresses
sType 0 Turn in 1 Turn out 2 all no page
func (*Wallet) GetSyncBlockOrder ¶
func (*Wallet) GetTxSpendInfo ¶
func (w *Wallet) GetTxSpendInfo(txId string) ([]*wtxmgr.AddrTxOutput, error)
func (*Wallet) GetUTXOByAddress ¶
func (*Wallet) GetUnspentAddrOutput ¶
func (*Wallet) GetUnspentUTXO ¶
func (*Wallet) ImportPrivateKey ¶
ImportPrivateKey imports a private key to the wallet and writes the new wallet to disk.
NOTE: If a block stamp is not provided, then the wallet's birthday will be set to the genesis block of the corresponding chain.
func (*Wallet) NewAddress ¶
NewAddress returns the next external chained address for a wallet.
func (*Wallet) NextAccount ¶
NextAccount creates the next account and returns its account number. The name must be unique to the account. In order to support automatic seed restoring, new accounts may not be created when all of the previous 100 accounts have no transaction history (this is a deviation from the BIP0044 spec, which allows no unused account gaps).
func (*Wallet) OnBlockConnected ¶
func (*Wallet) OnNodeExit ¶
func (w *Wallet) OnNodeExit(nodeExit *cmds.NodeExitNtfn)
func (*Wallet) OnRescanFinish ¶
func (w *Wallet) OnRescanFinish(rescanFinish *cmds.RescanFinishedNtfn)
func (*Wallet) OnRescanProgress ¶
func (w *Wallet) OnRescanProgress(rescanPro *cmds.RescanProgressNtfn)
func (*Wallet) OnTxAcceptedVerbose ¶
func (w *Wallet) OnTxAcceptedVerbose(c *client.Client, tx *j.DecodeRawTransactionResult)
func (*Wallet) OnTxConfirm ¶
func (w *Wallet) OnTxConfirm(txConfirm *cmds.TxConfirmResult)
func (*Wallet) SendOutputs ¶
func (w *Wallet) SendOutputs(coin2outputs []*TxOutput, coinId types.CoinID, account int64, satPerKb int64, byAddr string) (*string, error)
SendOutputs creates and sends payment transactions. It returns the transaction upon success.
func (*Wallet) SendPairs ¶
func (w *Wallet) SendPairs(amounts map[string]types.Amount, account int64, feeSatPerKb int64, lockHeight uint64, byAddress string) (string, error)
sendPairs creates and sends payment transactions. It returns the transaction hash in string format upon success All errors are returned in btcjson.RPCError format
func (*Wallet) SetSyncedToNum ¶
func (*Wallet) ShuttingDown ¶
ShuttingDown returns whether the wallet is currently in the process of shutting down or not.
func (*Wallet) Start ¶
func (w *Wallet) Start()
Start starts the goroutines necessary to manage a wallet.
func (*Wallet) UnLockManager ¶
func (*Wallet) Unlock ¶
Unlock unlocks the wallet's address manager and relocks it after timeout has expired. If the wallet is already unlocked and the new passphrase is correct, the current timeout is replaced with the new one. The wallet will be locked if the passphrase is incorrect or any other error occurs during the unlock.
func (*Wallet) UpdateBlock ¶
func (*Wallet) WaitForShutdown ¶
func (w *Wallet) WaitForShutdown()
WaitForShutdown blocks until all wallet goroutines have finished executing.
Directories ¶
Path | Synopsis |
---|---|
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining.
|
Package txrules provides transaction rules that should be followed by transaction authors for wide mempool acceptance and quick mining. |