acct

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: ISC Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressUTXOsSuffix = "-utxos"

	NormalUTXOType   = 0
	CoinbaseUTXOType = 1
	CLTVUTXOType     = 2
	TokenUTXOType    = 3
)
View Source
const (
	CurrentAcctInfoVersion = 2
)

Variables

View Source
var (
	// ByteOrder is the preferred byte order used for serializing numeric
	// fields for storage in the database.
	ByteOrder = binary.LittleEndian

	// BalanceBucketName is the name of the db bucket used to house to
	// Address -> Balance
	BalanceBucketName = []byte("acctbalance")

	// InfoBucketName is the name of the db bucket used to house to
	// account info
	InfoBucketName = []byte("acctinfo")
)

Functions

func DBDelACCTBalance

func DBDelACCTBalance(dbTx database.Tx, address string) error

func DBDelACCTUTXO

func DBDelACCTUTXO(dbTx database.Tx, address string, op *types.TxOutPoint) error

func DBDelACCTUTXOs

func DBDelACCTUTXOs(dbTx database.Tx, address string) error

func DBGetACCTUTXOs added in v1.0.17

func DBGetACCTUTXOs(dbTx database.Tx, address string) map[string]*AcctUTXO

func DBPutACCTBalance

func DBPutACCTBalance(dbTx database.Tx, address string, ab *AcctBalance) error

func DBPutACCTInfo

func DBPutACCTInfo(dbTx database.Tx, ai *AcctInfo) error

func DBPutACCTUTXO

func DBPutACCTUTXO(dbTx database.Tx, address string, op *types.TxOutPoint, au *AcctUTXO) error

func GetACCTUTXOKey

func GetACCTUTXOKey(address string) []byte

utxo

func OutpointKey

func OutpointKey(outpoint *types.TxOutPoint) []byte

func UseLogger

func UseLogger(logger l.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type AccountManager

type AccountManager struct {
	service.Service
	// contains filtered or unexported fields
}

account manager communicate with various backends for signing transactions.

func New

func New(chain *blockchain.BlockChain, cfg *config.Config) (*AccountManager, error)

func (*AccountManager) APIs

func (a *AccountManager) APIs() []api.API

func (*AccountManager) AddAddress added in v1.0.18

func (a *AccountManager) AddAddress(addr string) error

func (*AccountManager) Apply

func (a *AccountManager) Apply(add bool, op *types.TxOutPoint, entry interface{}) error

func (*AccountManager) Commit

func (a *AccountManager) Commit() error

func (*AccountManager) DelWatcher

func (a *AccountManager) DelWatcher(addr string, op *types.TxOutPoint)

func (*AccountManager) GetBalance

func (a *AccountManager) GetBalance(addr string) (uint64, error)

func (*AccountManager) GetUTXOs added in v1.0.17

func (a *AccountManager) GetUTXOs(addr string) ([]UTXOResult, error)

func (*AccountManager) Start

func (a *AccountManager) Start() error

func (*AccountManager) Stop

func (a *AccountManager) Stop() error

type AcctBalance

type AcctBalance struct {
	// contains filtered or unexported fields
}

func DBGetACCTBalance

func DBGetACCTBalance(dbTx database.Tx, address string) (*AcctBalance, error)

balance

func NewAcctBalance

func NewAcctBalance(normal uint64, norUTXONum uint32, locked uint64, locUTXONum uint32) *AcctBalance

func (*AcctBalance) Decode

func (ab *AcctBalance) Decode(r io.Reader) error

func (*AcctBalance) Encode

func (ab *AcctBalance) Encode(w io.Writer) error

func (*AcctBalance) IsEmpty

func (ab *AcctBalance) IsEmpty() bool

func (*AcctBalance) String

func (ab *AcctBalance) String() string

type AcctBalanceWatcher

type AcctBalanceWatcher struct {
	// contains filtered or unexported fields
}

func NewAcctBalanceWatcher

func NewAcctBalanceWatcher(address string, ab *AcctBalance) *AcctBalanceWatcher

func (*AcctBalanceWatcher) Add

func (aw *AcctBalanceWatcher) Add(op []byte, au AcctUTXOIWatcher)

func (*AcctBalanceWatcher) Del

func (aw *AcctBalanceWatcher) Del(op []byte)

func (*AcctBalanceWatcher) Get added in v1.0.17

func (*AcctBalanceWatcher) GetBalance

func (aw *AcctBalanceWatcher) GetBalance() uint64

func (*AcctBalanceWatcher) GetByOPS added in v1.0.17

func (aw *AcctBalanceWatcher) GetByOPS(ops string) AcctUTXOIWatcher

func (*AcctBalanceWatcher) Has

func (aw *AcctBalanceWatcher) Has(op []byte) bool

func (*AcctBalanceWatcher) Update

func (aw *AcctBalanceWatcher) Update(am *AccountManager) error

type AcctInfo

type AcctInfo struct {
	// contains filtered or unexported fields
}

func DBGetACCTInfo

func DBGetACCTInfo(dbTx database.Tx) (*AcctInfo, error)

info

func NewAcctInfo

func NewAcctInfo() *AcctInfo

func (*AcctInfo) Add added in v1.0.18

func (ai *AcctInfo) Add(addr string)

func (*AcctInfo) Decode

func (ai *AcctInfo) Decode(r io.Reader) error

func (*AcctInfo) Encode

func (ai *AcctInfo) Encode(w io.Writer) error

func (*AcctInfo) GetAddrTotal added in v1.0.18

func (ai *AcctInfo) GetAddrTotal() int

func (*AcctInfo) Has added in v1.0.18

func (ai *AcctInfo) Has(addr string) bool

func (*AcctInfo) IsCurrentVersion added in v1.0.18

func (ai *AcctInfo) IsCurrentVersion() bool

func (*AcctInfo) IsEmpty added in v1.0.18

func (ai *AcctInfo) IsEmpty() bool

func (*AcctInfo) String

func (ai *AcctInfo) String() string

type AcctUTXO

type AcctUTXO struct {
	// contains filtered or unexported fields
}

func NewAcctUTXO

func NewAcctUTXO() *AcctUTXO

func (*AcctUTXO) Decode

func (au *AcctUTXO) Decode(r io.Reader) error

func (*AcctUTXO) Encode

func (au *AcctUTXO) Encode(w io.Writer) error

func (*AcctUTXO) IsCLTV

func (au *AcctUTXO) IsCLTV() bool

func (*AcctUTXO) IsCoinbase

func (au *AcctUTXO) IsCoinbase() bool

func (*AcctUTXO) SetBalance

func (au *AcctUTXO) SetBalance(balance uint64)

func (*AcctUTXO) SetCLTV

func (au *AcctUTXO) SetCLTV()

func (*AcctUTXO) SetCoinbase

func (au *AcctUTXO) SetCoinbase()

func (*AcctUTXO) String

func (au *AcctUTXO) String() string

func (*AcctUTXO) TypeStr

func (au *AcctUTXO) TypeStr() string

type AcctUTXOIWatcher

type AcctUTXOIWatcher interface {
	Update(am *AccountManager) error
	GetBalance() uint64
	IsUnlocked() bool
	GetName() string
}

func BuildUTXOWatcher

func BuildUTXOWatcher(op []byte, au *AcctUTXO, entry *utxo.UtxoEntry, am *AccountManager) AcctUTXOIWatcher

type BalanceInfoResult added in v1.0.17

type BalanceInfoResult struct {
	CoinId  string       `json:"coinid"`
	Balance int64        `json:"balance"`
	UTXOs   []UTXOResult `json:"utxos,omitempty"`
}

type CLTVWatcher

type CLTVWatcher struct {
	// contains filtered or unexported fields
}

func NewCLTVWatcher

func NewCLTVWatcher(au *AcctUTXO, lockTime int64, isForkGenUTXO bool) *CLTVWatcher

func (*CLTVWatcher) GetBalance

func (cw *CLTVWatcher) GetBalance() uint64

func (*CLTVWatcher) GetName

func (cw *CLTVWatcher) GetName() string

func (*CLTVWatcher) IsUnlocked

func (cw *CLTVWatcher) IsUnlocked() bool

func (*CLTVWatcher) Lock

func (cw *CLTVWatcher) Lock()

func (*CLTVWatcher) Update

func (cw *CLTVWatcher) Update(am *AccountManager) error

type CoinbaseWatcher

type CoinbaseWatcher struct {
	// contains filtered or unexported fields
}

func NewCoinbaseWatcher

func NewCoinbaseWatcher(au *AcctUTXO, target meerdag.IBlock) *CoinbaseWatcher

func (*CoinbaseWatcher) GetBalance

func (cw *CoinbaseWatcher) GetBalance() uint64

func (*CoinbaseWatcher) GetName

func (cw *CoinbaseWatcher) GetName() string

func (*CoinbaseWatcher) IsUnlocked

func (cw *CoinbaseWatcher) IsUnlocked() bool

func (*CoinbaseWatcher) Lock

func (cw *CoinbaseWatcher) Lock()

func (*CoinbaseWatcher) Update

func (cw *CoinbaseWatcher) Update(am *AccountManager) error

type PublicAccountManagerAPI

type PublicAccountManagerAPI struct {
	// contains filtered or unexported fields
}

PublicEthereumAPI provides an API to access Ethereum full node-related information.

func NewPublicAccountManagerAPI

func NewPublicAccountManagerAPI(a *AccountManager) *PublicAccountManagerAPI

NewPublicEthereumAPI creates a new Ethereum protocol API for full nodes.

func (*PublicAccountManagerAPI) AddBalance added in v1.0.18

func (api *PublicAccountManagerAPI) AddBalance(addr string) (interface{}, error)

func (*PublicAccountManagerAPI) GetAcctInfo

func (api *PublicAccountManagerAPI) GetAcctInfo() (interface{}, error)

func (*PublicAccountManagerAPI) GetBalance

func (api *PublicAccountManagerAPI) GetBalance(addr string, coinID types.CoinID) (interface{}, error)

func (*PublicAccountManagerAPI) GetBalanceInfo added in v1.0.17

func (api *PublicAccountManagerAPI) GetBalanceInfo(addr string, coinID types.CoinID) (interface{}, error)

type UTXOOP

type UTXOOP struct {
	// contains filtered or unexported fields
}

type UTXOResult added in v1.0.17

type UTXOResult struct {
	Type      string `json:"type"`
	Amount    uint64 `json:"amount"`
	PreTxHash string `json:"txid"`
	PreOutIdx uint32 `json:"idx"`
	Status    string `json:"status"`
}

Jump to

Keyboard shortcuts

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