Documentation ¶
Overview ¶
Package account stores and tracks accounts within a Bytom Core.
Package account stores and tracks accounts within a Bytom Core.
Index ¶
- Constants
- Variables
- func Annotated(a *Account) *query.AnnotatedAccount
- func ContractKey(hash common.Hash) []byte
- func ContractUTXOKey(id bc.Hash) []byte
- func Key(name string) []byte
- func MergeSpendAction(actions []txbuilder.Action) []txbuilder.Action
- func StandardUTXOKey(id bc.Hash) []byte
- func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.SigningInstruction, error)
- type Account
- type CtrlProgram
- type Image
- type ImageSlice
- type Manager
- func (m *Manager) AddUnconfirmedUtxo(utxos []*UTXO)
- func (m *Manager) Backup() (*Image, error)
- func (m *Manager) Create(xpubs []chainkd.XPub, quorum int, alias string) (*Account, error)
- func (m *Manager) CreateAddress(accountID string, change bool) (cp *CtrlProgram, err error)
- func (m *Manager) DecodeSpendAction(data []byte) (txbuilder.Action, error)
- func (m *Manager) DecodeSpendUTXOAction(data []byte) (txbuilder.Action, error)
- func (m *Manager) DeleteAccount(aliasOrID string) (err error)
- func (m *Manager) FindByAlias(alias string) (*Account, error)
- func (m *Manager) FindByID(id string) (*Account, error)
- func (m *Manager) GetAccountByProgram(program *CtrlProgram) (*Account, error)
- func (m *Manager) GetAliasByID(id string) string
- func (m *Manager) GetCoinbaseControlProgram() ([]byte, error)
- func (m *Manager) GetContractIndex(accountID string) uint64
- func (m *Manager) GetProgramByAddress(address string) (*CtrlProgram, error)
- func (m *Manager) IsLocalControlProgram(prog []byte) bool
- func (m *Manager) ListAccounts(id string) ([]*Account, error)
- func (m *Manager) ListControlProgram() ([]*CtrlProgram, error)
- func (m *Manager) ListUnconfirmedUtxo(isSmartContract bool) []*UTXO
- func (m *Manager) RemoveUnconfirmedUtxo(hashes []*bc.Hash)
- func (m *Manager) Restore(image *Image) error
- type UTXO
Constants ¶
const ( //UTXOPreFix is StandardUTXOKey prefix UTXOPreFix = "ACU:" //SUTXOPrefix is ContractUTXOKey prefix SUTXOPrefix = "SCU:" )
Variables ¶
var ( ErrDuplicateAlias = errors.New("duplicate account alias") ErrFindAccount = errors.New("fail to find account") ErrMarshalAccount = errors.New("failed marshal account") ErrInvalidAddress = errors.New("invalid address") ErrFindCtrlProgram = errors.New("fail to find account control program") )
pre-define errors for supporting bytom errorFormatter
var ( ErrInsufficient = errors.New("reservation found insufficient funds") ErrImmature = errors.New("reservation found immature funds") ErrReserved = errors.New("reservation found outputs already reserved") ErrMatchUTXO = errors.New("can't find utxo with given hash") ErrReservation = errors.New("couldn't find reservation") )
pre-define error types
Functions ¶
func Annotated ¶
func Annotated(a *Account) *query.AnnotatedAccount
Annotated init an annotated account object
func ContractKey ¶ added in v0.5.0
ContractKey account control promgram store prefix
func ContractUTXOKey ¶
ContractUTXOKey makes a smart contract unspent outputs key to store
func MergeSpendAction ¶ added in v1.0.2
MergeSpendAction merge common assetID and accountID spend action
func StandardUTXOKey ¶
StandardUTXOKey makes an account unspent outputs key to store
func UtxoToInputs ¶
func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.SigningInstruction, error)
UtxoToInputs convert an utxo to the txinput
Types ¶
type CtrlProgram ¶
type CtrlProgram struct { AccountID string Address string KeyIndex uint64 ControlProgram []byte Change bool // Mark whether this control program is for UTXO change }
CtrlProgram is structure of account control program
type Image ¶ added in v0.5.0
type Image struct {
Slice []*ImageSlice `json:"slices"`
}
Image is the struct for hold export account data
type ImageSlice ¶ added in v0.5.0
type ImageSlice struct { Account *Account `json:"account"` ContractIndex uint64 `json:"contract_index"` }
ImageSlice record info of single account
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager stores accounts and their associated control programs.
func NewManager ¶
NewManager creates a new account manager
func (*Manager) AddUnconfirmedUtxo ¶ added in v1.0.4
AddUnconfirmedUtxo add untxo list to utxoKeeper
func (*Manager) CreateAddress ¶
func (m *Manager) CreateAddress(accountID string, change bool) (cp *CtrlProgram, err error)
CreateAddress generate an address for the select account
func (*Manager) DecodeSpendAction ¶
DecodeSpendAction unmarshal JSON-encoded data of spend action
func (*Manager) DecodeSpendUTXOAction ¶
DecodeSpendUTXOAction unmarshal JSON-encoded data of spend utxo action
func (*Manager) DeleteAccount ¶
DeleteAccount deletes the account's ID or alias matching accountInfo.
func (*Manager) FindByAlias ¶
FindByAlias retrieves an account's Signer record by its alias
func (*Manager) GetAccountByProgram ¶ added in v1.0.2
func (m *Manager) GetAccountByProgram(program *CtrlProgram) (*Account, error)
GetAccountByProgram return Account by given CtrlProgram
func (*Manager) GetAliasByID ¶
GetAliasByID return the account alias by given ID
func (*Manager) GetCoinbaseControlProgram ¶
GetCoinbaseControlProgram will return a coinbase script
func (*Manager) GetContractIndex ¶ added in v1.0.4
GetContractIndex return the current index
func (*Manager) GetProgramByAddress ¶ added in v1.0.2
func (m *Manager) GetProgramByAddress(address string) (*CtrlProgram, error)
GetProgramByAddress return CtrlProgram by given address
func (*Manager) IsLocalControlProgram ¶
IsLocalControlProgram check is the input control program belong to local
func (*Manager) ListAccounts ¶
ListAccounts will return the accounts in the db
func (*Manager) ListControlProgram ¶
func (m *Manager) ListControlProgram() ([]*CtrlProgram, error)
ListControlProgram return all the local control program
func (*Manager) ListUnconfirmedUtxo ¶ added in v1.0.4
func (*Manager) RemoveUnconfirmedUtxo ¶ added in v1.0.4
RemoveUnconfirmedUtxo remove utxos from the utxoKeeper