Documentation
¶
Index ¶
- func MockServer() (*httptest.Server, func())
- type APIMux
- type Address
- type AddressPos
- type Backup
- type Balance
- type BlockstreamChain
- func (c *BlockstreamChain) GetFees() (map[string]float32, error)
- func (c *BlockstreamChain) GetTickers() (map[string]Ticker, error)
- func (c *BlockstreamChain) GetTxLink() string
- func (c *BlockstreamChain) GetTxs(address string) ([]Tx, error)
- func (c *BlockstreamChain) GetUTXO(address string) ([]Unspent, error)
- func (c *BlockstreamChain) PushTx(hex string) (string, error)
- type BlockstreamTx
- type BlockstreamUTXO
- type Chain
- type Config
- type Handler
- type LoginType
- type SendFees
- type Smtp
- type SmtpConfig
- type Ticker
- type Tx
- type UTXO
- type Unspent
- type Vcode
- type Wallet
- func (w *Wallet) AddressPoss(offset int, limit int) []AddressPos
- func (w *Wallet) Addresses() []AddressPos
- func (w *Wallet) Balance() *Balance
- func (w *Wallet) Lock()
- func (w *Wallet) NewAddress(typ string) (*Address, error)
- func (w *Wallet) SendFees(sendValue uint64, feesPerKB int) (*SendFees, error)
- func (w *Wallet) Txs(offset int, limit int) []Tx
- func (w *Wallet) Unlock()
- func (w *Wallet) Unspents(sendAmount uint64) ([]UTXO, error)
- func (w *Wallet) UpdateTxs(addr string, txs []Tx)
- func (w *Wallet) UpdateUnspents(addr string, unspents []Unspent)
- type WalletDB
- func (wdb *WalletDB) Addresses(uid string, offset int, limit int) ([]AddressPos, error)
- func (wdb *WalletDB) Balance(uid string) (*Balance, error)
- func (wdb *WalletDB) Close()
- func (wdb *WalletDB) CreateWallet(uid string, cliMasterPubKey string) error
- func (wdb *WalletDB) GetBackup(uid string) (Backup, error)
- func (wdb *WalletDB) MasterPrvKey(uid string) (string, error)
- func (wdb *WalletDB) NewAddress(uid string, typ string) (*Address, error)
- func (wdb *WalletDB) Open(dir string) error
- func (wdb *WalletDB) SendFees(uid string, priority string, sendAmount uint64) (*SendFees, error)
- func (wdb *WalletDB) StoreBackup(uid string, email string, did string, cloudService string, ...) error
- func (wdb *WalletDB) Txs(uid string, offset int, limit int) ([]Tx, error)
- func (wdb *WalletDB) Unspents(uid string, amount uint64) ([]UTXO, error)
- func (wdb *WalletDB) Wallet(uid string) *Wallet
- type WalletStore
- type WalletSyncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockServer ¶
Types ¶
type Address ¶
type Address struct {
Pos uint32 `json:"pos"`
Address string `json:"address"`
Balance Balance `json:"balance"`
Txs []Tx `json:"txs"`
Unspents []Unspent `json:"unspents"`
// contains filtered or unexported fields
}
Address --
type AddressPos ¶
AddressPos --
type Balance ¶
type Balance struct {
TotalBalance uint64 `json:"total_balance"`
UnconfirmedBalance uint64 `json:"unconfirmed_balance"`
}
Balance --
type BlockstreamChain ¶
type BlockstreamChain struct {
// contains filtered or unexported fields
}
BlockstreamChain --
func (*BlockstreamChain) GetFees ¶
func (c *BlockstreamChain) GetFees() (map[string]float32, error)
GetFees -- used to get the fees from the chain mempool.
func (*BlockstreamChain) GetTickers ¶
func (c *BlockstreamChain) GetTickers() (map[string]Ticker, error)
func (*BlockstreamChain) GetTxLink ¶
func (c *BlockstreamChain) GetTxLink() string
GetTxLink -- get the tx web link.
func (*BlockstreamChain) GetTxs ¶
func (c *BlockstreamChain) GetTxs(address string) ([]Tx, error)
GetTxs -- used to get transactions by address.
type BlockstreamTx ¶
type BlockstreamTx struct {
Txid string `json:"txid"`
Version int64 `json:"version"`
Locktime int64 `json:"locktime"`
Vin []struct {
Txid string `json:"txid"`
Vout int `json:"vout"`
Prevout struct {
Scriptpubkey string `json:"scriptpubkey"`
ScriptpubkeyAsm string `json:"scriptpubkey_asm"`
ScriptpubkeyAddress string `json:"scriptpubkey_address"`
ScriptpubkeyType string `json:"scriptpubkey_type"`
Value int64 `json:"value"`
} `json:"prevout"`
Scriptsig string `json:"scriptsig"`
ScriptsigAsm string `json:"scriptsig_asm"`
Witness []string `json:"witness"`
IsCoinbase bool `json:"is_coinbase"`
Sequence int64 `json:"sequence"`
} `json:"vin"`
Vout []struct {
Scriptpubkey string `json:"scriptpubkey"`
ScriptpubkeyAsm string `json:"scriptpubkey_asm"`
ScriptpubkeyAddress string `json:"scriptpubkey_address"`
ScriptpubkeyType string `json:"scriptpubkey_type"`
Value int64 `json:"value"`
} `json:"vout"`
Size int `json:"size"`
Weight int `json:"weight"`
Fee int64 `json:"fee"`
Status struct {
Confirmed bool `json:"confirmed"`
BlockHeight int64 `json:"block_height"`
BlockHash string `json:"block_hash"`
BlockTime int64 `json:"block_time"`
} `json:"status"`
}
BlockstreamTx --
type BlockstreamUTXO ¶
type BlockstreamUTXO struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Status struct {
Confirmed bool `json:"confirmed"`
BlockHeight uint32 `json:"block_height"`
BlockHash string `json:"block_hash"`
BlockTime uint32 `json:"block_time"`
} `json:"status"`
Value uint64 `json:"value"`
}
BlockstreamUTXO --
type Chain ¶
type Chain interface {
GetTxs(address string) ([]Tx, error)
GetFees() (map[string]float32, error)
GetUTXO(address string) ([]Unspent, error)
GetTickers() (map[string]Ticker, error)
GetTxLink() string
PushTx(hex string) (string, error)
}
Chain --
func NewBlockstreamChain ¶
NewBlockstreamChain -- creates new BlockstreamChain.
type Config ¶
type Config struct {
DataDir string `json:"datadir"`
ChainNet string `json:"chainnet"`
Endpoint string `json:"endpoint"`
TokenSecret string `json:"token_secret"`
SpvProvider string `json:"spv_provider"`
EnableVCode bool `json:"enable_vcode"`
ForceRecover bool `json:"force_recover"`
VCodeExpired int `json:"vcode_expired"`
WalletSyncIntervalMs int `json:"wallet_sync_interval_ms"`
Smtp *SmtpConfig `json:"smtp"`
}
Config --
func LoadConfig ¶
LoadConfig -- used to load the config from file.
func MockConfig ¶
func MockConfig() *Config
func (*Config) UnmarshalJSON ¶
UnmarshalJSON -- built-in method for set default value when Unmarshal.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler --
func NewHandler ¶
NewHandler -- creates new Handler.
type SendFees ¶
type SendFees struct {
Fees uint64 `json:"fees"`
TotalValue uint64 `json:"total_value"`
SendableValue uint64 `json:"sendable_value"`
}
SendFees --
type Smtp ¶
type Smtp struct {
// contains filtered or unexported fields
}
Smtp --
type SmtpConfig ¶
type SmtpConfig struct {
Server string `json:"server"`
Port int `json:"port"`
UserName string `json:"username"`
Password string `json:"password"`
BackupTo string `json:"backup_to"`
}
SmtpConfig --
type Ticker ¶
type Ticker struct {
One5M float64 `json:"15m"`
Last float64 `json:"last"`
Buy float64 `json:"buy"`
Sell float64 `json:"sell"`
Symbol string `json:"symbol"`
}
Ticker --
type Tx ¶
type Tx struct {
Txid string `json:"txid"`
Fee int64 `json:"fee"`
Data string `json:"data"`
Link string `json:"link"`
Value int64 `json:"value"`
Confirmed bool `json:"confirmed"`
BlockTime int64 `json:"block_time"`
BlockHeight int64 `json:"block_height"`
}
Tx --
type UTXO ¶
type UTXO struct {
Pos uint32 `json:"pos"`
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Value uint64 `json:"value"`
Address string `json:"address"`
Confirmed bool `json:"confirmed"`
SvrPubKey string `json:"svrpubkey"`
Scriptpubkey string `json:"Scriptpubkey"`
}
UTXO --
type Unspent ¶
type Unspent struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Value uint64 `json:"value"`
Confirmed bool `json:"confirmed"`
BlockTime uint32 `json:"block_time"`
BlockHeight uint32 `json:"block_height"`
Scriptpubkey string `json:"Scriptpubkey"`
}
Unspent --
type Vcode ¶
type Vcode struct {
// contains filtered or unexported fields
}
Vcode --
type Wallet ¶
type Wallet struct {
UID string `json:"uid"`
DID string `json:"did"`
Backup Backup `json:"backup"`
LastPos uint32 `json:"lastpos"`
Address map[string]*Address `json:"address"`
SvrMasterPrvKey string `json:"svrmasterprvkey"`
CliMasterPubKey string `json:"climasterpubkey"`
// contains filtered or unexported fields
}
Wallet --
func (*Wallet) AddressPoss ¶
func (w *Wallet) AddressPoss(offset int, limit int) []AddressPos
AddressPoss -- used to return the AddressPoss from offset to offset+limit.
func (*Wallet) Addresses ¶
func (w *Wallet) Addresses() []AddressPos
Addresses -- used to returns all the address of the wallet.
func (*Wallet) Lock ¶
func (w *Wallet) Lock()
Lock -- used to lock the wallet entry for thread-safe purposes.
func (*Wallet) NewAddress ¶
NewAddress -- used to generate new address.
func (*Wallet) Unlock ¶
func (w *Wallet) Unlock()
Unlock -- used to unlock the wallet entry for thread-safe purposes.
func (*Wallet) Unspents ¶
Unspents -- used to return unspent which all the value upper than the amount.
func (*Wallet) UpdateUnspents ¶
UpdateUnspents -- update the address balance/unspent which fetchs from the chain.
type WalletDB ¶
type WalletDB struct {
// contains filtered or unexported fields
}
WalletDB --
func NewWalletDB ¶
NewWalletDB -- creates new WalletDB.
func (*WalletDB) CreateWallet ¶
CreateWallet -- used to create a wallet file.
func (*WalletDB) NewAddress ¶
NewAddress -- used to generate new address of this uid.
func (*WalletDB) StoreBackup ¶
type WalletStore ¶
type WalletStore struct {
// contains filtered or unexported fields
}
WalletStore --
func NewWalletStore ¶
func NewWalletStore(log *xlog.Log, conf *Config) *WalletStore
NewWalletStore -- creates new WalletStore.
func (*WalletStore) AllUID ¶
func (s *WalletStore) AllUID() []string
AllUID -- used to clone all the wallet uids.
func (*WalletStore) FeesPerKB ¶
func (s *WalletStore) FeesPerKB(priority string) int
FeesPerKB -- used to return the fees.
func (*WalletStore) Get ¶
func (s *WalletStore) Get(uid string) *Wallet
Get -- used to get a wallet from the wallets list. Returns nil if not exists.
func (*WalletStore) Open ¶
func (s *WalletStore) Open(dir string) error
Open -- used to open the dir database.
func (*WalletStore) Read ¶
func (s *WalletStore) Read(path string) (*Wallet, error)
Read -- reads a wallet from the file.
func (*WalletStore) Write ¶
func (s *WalletStore) Write(wallet *Wallet) error
Write -- write wallet to the file. Thread-Safe.
type WalletSyncer ¶
type WalletSyncer struct {
// contains filtered or unexported fields
}
WalletSyncer --
func NewWalletSyncer ¶
func NewWalletSyncer(log *xlog.Log, conf *Config, chain Chain, store *WalletStore) *WalletSyncer
NewWalletSyncer -- creates new WalletSyncer.
func (*WalletSyncer) Start ¶
func (ws *WalletSyncer) Start()
Start -- used to start the sync worker talk with chain.