wallet

package
v1.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2018 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TxPrefix is wallet database transactions prefix
	TxPrefix = "TXS:"
	//TxIndexPrefix is wallet database tx index prefix
	TxIndexPrefix = "TID:"
)
View Source
const (
	//UnconfirmedTxPrefix is txpool unconfirmed transactions prefix
	UnconfirmedTxPrefix      = "UTXS:"
	UnconfirmedTxCheckPeriod = 30 * time.Minute
	MaxUnconfirmedTxDuration = 24 * time.Hour
)
View Source
const (
	//SINGLE single sign
	SINGLE = 1
	//channel size for notifying tx msg
	NewTxChSize = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance struct {
	AccountID       string                 `json:"account_id"`
	Alias           string                 `json:"account_alias"`
	AssetAlias      string                 `json:"asset_alias"`
	AssetID         string                 `json:"asset_id"`
	Amount          uint64                 `json:"amount"`
	AssetDefinition map[string]interface{} `json:"asset_definition"`
}

AccountBalance account balance

type SortByTimestamp

type SortByTimestamp []*query.AnnotatedTx

SortByTimestamp implements sort.Interface for AnnotatedTx slices

func (SortByTimestamp) Len

func (a SortByTimestamp) Len() int

func (SortByTimestamp) Less

func (a SortByTimestamp) Less(i, j int) bool

func (SortByTimestamp) Swap

func (a SortByTimestamp) Swap(i, j int)

type StatusInfo

type StatusInfo struct {
	WorkHeight uint64
	WorkHash   bc.Hash
	BestHeight uint64
	BestHash   bc.Hash
}

StatusInfo is base valid block info to handle orphan block rollback

type Summary

type Summary struct {
	Type         string             `json:"type"`
	AssetID      bc.AssetID         `json:"asset_id,omitempty"`
	AssetAlias   string             `json:"asset_alias,omitempty"`
	Amount       uint64             `json:"amount,omitempty"`
	AccountID    string             `json:"account_id,omitempty"`
	AccountAlias string             `json:"account_alias,omitempty"`
	Arbitrary    chainjson.HexBytes `json:"arbitrary,omitempty"`
}

Summary is the struct of transaction's input and output summary

type TxSummary

type TxSummary struct {
	ID        bc.Hash   `json:"tx_id"`
	Timestamp uint64    `json:"block_time"`
	Inputs    []Summary `json:"inputs"`
	Outputs   []Summary `json:"outputs"`
}

TxSummary is the struct of transaction summary

type Wallet

type Wallet struct {
	DB db.DB

	AccountMgr *account.Manager
	AssetReg   *asset.Registry
	Hsm        *pseudohsm.HSM
	// contains filtered or unexported fields
}

Wallet is related to storing account unspent outputs

func NewWallet

func NewWallet(walletDB db.DB, account *account.Manager, asset *asset.Registry, hsm *pseudohsm.HSM, chain *protocol.Chain) (*Wallet, error)

NewWallet return a new wallet instance

func (*Wallet) AddUnconfirmedTx

func (w *Wallet) AddUnconfirmedTx(tx *types.Tx)

AddUnconfirmedTx handle wallet status update when tx add into txpool

func (*Wallet) AttachBlock

func (w *Wallet) AttachBlock(block *types.Block) error

AttachBlock attach a new block

func (*Wallet) BuildAnnotatedInput

func (w *Wallet) BuildAnnotatedInput(tx *types.Tx, i uint32) *query.AnnotatedInput

BuildAnnotatedInput build the annotated input.

func (*Wallet) BuildAnnotatedOutput

func (w *Wallet) BuildAnnotatedOutput(tx *types.Tx, idx int) *query.AnnotatedOutput

BuildAnnotatedOutput build the annotated output.

func (*Wallet) DetachBlock

func (w *Wallet) DetachBlock(block *types.Block) error

DetachBlock detach a block and rollback state

func (*Wallet) GetAccountBalances

func (w *Wallet) GetAccountBalances(id string) ([]AccountBalance, error)

GetAccountBalances return all account balances

func (*Wallet) GetAccountUtxos

func (w *Wallet) GetAccountUtxos(id string, unconfirmed, isSmartContract bool) []*account.UTXO

GetAccountUtxos return all account unspent outputs

func (*Wallet) GetTransactionByTxID

func (w *Wallet) GetTransactionByTxID(txID string) (*query.AnnotatedTx, error)

GetTransactionByTxID get transaction by txID

func (*Wallet) GetTransactions

func (w *Wallet) GetTransactions(accountID string) ([]*query.AnnotatedTx, error)

GetTransactions get all walletDB transactions, and filter transactions by accountID optional

func (*Wallet) GetTransactionsSummary

func (w *Wallet) GetTransactionsSummary(transactions []*query.AnnotatedTx) []TxSummary

GetTransactionsSummary get transactions summary

func (*Wallet) GetTxCh

func (w *Wallet) GetTxCh() chan *types.Tx

func (*Wallet) GetUnconfirmedTxByTxID

func (w *Wallet) GetUnconfirmedTxByTxID(txID string) (*query.AnnotatedTx, error)

GetUnconfirmedTxByTxID get unconfirmed transaction by txID

func (*Wallet) GetUnconfirmedTxs

func (w *Wallet) GetUnconfirmedTxs(accountID string) ([]*query.AnnotatedTx, error)

GetUnconfirmedTxs get account unconfirmed transactions, filter transactions by accountID when accountID is not empty

func (*Wallet) GetWalletStatusInfo

func (w *Wallet) GetWalletStatusInfo() StatusInfo

GetWalletStatusInfo return current wallet StatusInfo

func (*Wallet) RemoveUnconfirmedTx

func (w *Wallet) RemoveUnconfirmedTx(tx *types.Tx)

RemoveUnconfirmedTx handle wallet status update when tx removed from txpool

func (*Wallet) RescanBlocks

func (w *Wallet) RescanBlocks()

RescanBlocks provide a trigger to rescan blocks

Jump to

Keyboard shortcuts

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