Documentation
¶
Index ¶
- Constants
- func All(tx UnconfirmedTxn) bool
- func DefaultWalker(hps []coin.HashPair) cipher.SHA256
- func DropletPrecisionCheck(amount uint64) error
- func GetDistributionAddresses() []string
- func GetLockedDistributionAddresses() []string
- func GetUnlockedDistributionAddresses() []string
- func IsValid(tx UnconfirmedTxn) bool
- func MaxDropletDivisor() uint64
- func NewErrTxnViolatesHardConstraint(err error) error
- func NewErrTxnViolatesSoftConstraint(err error) error
- func OpenDB(dbFile string, readOnly bool) (*bolt.DB, error)
- func ReadableOutputsToUxBalances(ros ReadableOutputs) ([]wallet.UxBalance, error)
- func ToAddresses(addresses []cipher.Address) func(UnconfirmedTxn) bool
- func TransactionIsLocked(inUxs coin.UxArray) bool
- func TransactionToJSON(tx coin.Transaction) (string, error)
- func VerifyBlockTxnConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
- func VerifySingleTxnHardConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
- func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error
- type BlockListener
- type Blockchain
- func (bc *Blockchain) BindListener(ls BlockListener)
- func (bc *Blockchain) ExecuteBlockWithTx(tx *bolt.Tx, sb *coin.SignedBlock) error
- func (bc *Blockchain) GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
- func (bc *Blockchain) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
- func (bc Blockchain) GetBlocks(start, end uint64) []coin.SignedBlock
- func (bc *Blockchain) GetGenesisBlock() *coin.SignedBlock
- func (bc Blockchain) GetLastBlocks(num uint64) []coin.SignedBlock
- func (bc Blockchain) Head() (*coin.SignedBlock, error)
- func (bc *Blockchain) HeadSeq() uint64
- func (bc Blockchain) Len() uint64
- func (bc Blockchain) NewBlock(txns coin.Transactions, currentTime uint64) (*coin.Block, error)
- func (bc *Blockchain) Notify(b coin.Block)
- func (bc *Blockchain) Time() uint64
- func (bc Blockchain) TransactionFee(t *coin.Transaction) (uint64, error)
- func (bc *Blockchain) Unspent() blockdb.UnspentPool
- func (bc *Blockchain) UpdateDB(f func(t *bolt.Tx) error) error
- func (bc Blockchain) VerifyBlockTxnConstraints(tx coin.Transaction) error
- func (bc Blockchain) VerifySingleTxnAllConstraints(tx coin.Transaction, maxSize int) error
- func (bc Blockchain) VerifySingleTxnHardConstraints(tx coin.Transaction) error
- type BlockchainMetadata
- type BlockchainParser
- type Blockchainer
- type BuildInfo
- type Config
- type ErrTxnViolatesHardConstraint
- type ErrTxnViolatesSoftConstraint
- type Option
- type ParserOption
- type RPC
- func (rpc *RPC) CreateAndSignTransaction(wltID string, password []byte, vld wallet.Validator, ...) (*coin.Transaction, error)
- func (rpc *RPC) CreateAndSignTransactionAdvanced(params wallet.CreateTransactionParams, sv wallet.Validator, ...) (*coin.Transaction, []wallet.UxBalance, error)
- func (rpc *RPC) CreateWallet(wltName string, options wallet.Options, bg wallet.BalanceGetter) (*wallet.Wallet, error)
- func (rpc RPC) GetAddressTxns(v *Visor, addr cipher.Address) ([]Transaction, error)
- func (rpc RPC) GetBlock(v *Visor, seq uint64) (*coin.SignedBlock, error)
- func (rpc RPC) GetBlockBySeq(v *Visor, n uint64) (*coin.SignedBlock, error)
- func (rpc RPC) GetBlockchainMetadata(v *Visor) (*BlockchainMetadata, error)
- func (rpc RPC) GetBlocks(v *Visor, start, end uint64) []coin.SignedBlock
- func (rpc *RPC) GetBuildInfo() BuildInfo
- func (rpc RPC) GetLastBlocks(v *Visor, num uint64) []coin.SignedBlock
- func (rpc RPC) GetTransaction(v *Visor, txHash cipher.SHA256) (*Transaction, error)
- func (rpc RPC) GetUnconfirmedReceiving(v *Visor, addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (rpc RPC) GetUnconfirmedSpends(v *Visor, addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (rpc RPC) GetUnconfirmedTxns(v *Visor, addresses []cipher.Address) []UnconfirmedTxn
- func (rpc RPC) GetUnspent(v *Visor) blockdb.UnspentPool
- func (rpc *RPC) GetWallet(wltID string) (*wallet.Wallet, error)
- func (rpc *RPC) GetWalletAddresses(wltID string) ([]cipher.Address, error)
- func (rpc *RPC) GetWallets() (wallet.Wallets, error)
- func (rpc *RPC) NewAddresses(wltName string, num uint64) ([]cipher.Address, error)
- func (rpc *RPC) ReloadWallets() error
- func (rpc *RPC) UnloadWallet(id string)
- func (rpc *RPC) UpdateWalletLabel(wltID, label string) error
- type ReadableBlock
- type ReadableBlockBody
- type ReadableBlockHeader
- type ReadableBlocks
- type ReadableOutput
- type ReadableOutputSet
- type ReadableOutputs
- type ReadableTransaction
- type ReadableTransactionInput
- type ReadableTransactionOutput
- type ReadableUnconfirmedTxn
- type Richlist
- type RichlistBalance
- type Transaction
- type TransactionJSON
- type TransactionOutputJSON
- type TransactionResult
- type TransactionResults
- type TransactionStatus
- type TxFilter
- type TxnUnspents
- type UnconfirmedTxn
- type UnconfirmedTxnPool
- func (utp *UnconfirmedTxnPool) FilterKnown(txns []cipher.SHA256) []cipher.SHA256
- func (utp *UnconfirmedTxnPool) ForEach(f func(cipher.SHA256, *UnconfirmedTxn) error) error
- func (utp *UnconfirmedTxnPool) Get(key cipher.SHA256) (*UnconfirmedTxn, bool)
- func (utp *UnconfirmedTxnPool) GetIncomingOutputs(bh coin.BlockHeader) coin.UxArray
- func (utp *UnconfirmedTxnPool) GetKnown(txns []cipher.SHA256) coin.Transactions
- func (utp *UnconfirmedTxnPool) GetSpendingOutputs(bcUnspent blockdb.UnspentPool) (coin.UxArray, error)
- func (utp *UnconfirmedTxnPool) GetTxHashes(filter func(tx UnconfirmedTxn) bool) (hashes []cipher.SHA256)
- func (utp *UnconfirmedTxnPool) GetTxns(filter func(tx UnconfirmedTxn) bool) (txns []UnconfirmedTxn)
- func (utp *UnconfirmedTxnPool) GetUnspentsOfAddr(addr cipher.Address) coin.UxArray
- func (utp *UnconfirmedTxnPool) InjectTransaction(bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
- func (utp *UnconfirmedTxnPool) Len() int
- func (utp *UnconfirmedTxnPool) RawTxns() coin.Transactions
- func (utp *UnconfirmedTxnPool) RecvOfAddresses(bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
- func (utp *UnconfirmedTxnPool) Refresh(bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) RemoveInvalid(bc Blockchainer) ([]cipher.SHA256, error)
- func (utp *UnconfirmedTxnPool) RemoveTransactions(txns []cipher.SHA256) error
- func (utp *UnconfirmedTxnPool) RemoveTransactionsWithTx(tx *bolt.Tx, txns []cipher.SHA256)
- func (utp *UnconfirmedTxnPool) SetAnnounced(h cipher.SHA256, t time.Time) error
- func (utp *UnconfirmedTxnPool) SpendsOfAddresses(addrs []cipher.Address, unspent blockdb.UnspentGetter) (coin.AddressUxOuts, error)
- type UnconfirmedTxnPooler
- type UnspentGetFunc
- type Visor
- func (vs *Visor) AddressBalance(auxs coin.AddressUxOuts) (uint64, uint64, error)
- func (vs *Visor) CreateAndExecuteBlock() (coin.SignedBlock, error)
- func (vs *Visor) CreateBlock(when uint64) (coin.SignedBlock, error)
- func (vs *Visor) CreateWallet(wltName string, opts wallet.Options) (*wallet.Wallet, error)
- func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error
- func (vs *Visor) GenesisPreconditions()
- func (vs Visor) GetAddrUxOuts(address cipher.Address) ([]*historydb.UxOut, error)
- func (vs *Visor) GetAddressTxns(a cipher.Address) ([]Transaction, error)
- func (vs *Visor) GetAllUnconfirmedTxns() []UnconfirmedTxn
- func (vs *Visor) GetAllValidUnconfirmedTxHashes() []cipher.SHA256
- func (vs Visor) GetBalanceOfAddrs(addrs []cipher.Address) ([]wallet.BalancePair, error)
- func (vs *Visor) GetBlock(seq uint64) (*coin.SignedBlock, error)
- func (vs *Visor) GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
- func (vs *Visor) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
- func (vs *Visor) GetBlockchainMetadata() (*BlockchainMetadata, error)
- func (vs *Visor) GetBlocks(start, end uint64) []coin.SignedBlock
- func (vs Visor) GetHeadBlock() (*coin.SignedBlock, error)
- func (vs *Visor) GetLastBlocks(num uint64) []coin.SignedBlock
- func (vs *Visor) GetSignedBlocksSince(seq, ct uint64) ([]coin.SignedBlock, error)
- func (vs *Visor) GetTransaction(txHash cipher.SHA256) (*Transaction, error)
- func (vs *Visor) GetTransactions(flts ...TxFilter) ([]Transaction, error)
- func (vs *Visor) GetUnconfirmedTxns(filter func(UnconfirmedTxn) bool) []UnconfirmedTxn
- func (vs *Visor) GetUnspentOutputs() ([]coin.UxOut, error)
- func (vs Visor) GetUxOutByID(id cipher.SHA256) (*historydb.UxOut, error)
- func (vs *Visor) HeadBkSeq() uint64
- func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error)
- func (vs *Visor) InjectTransactionStrict(txn coin.Transaction) (bool, error)
- func (vs *Visor) RefreshUnconfirmed() ([]cipher.SHA256, error)
- func (vs *Visor) RemoveInvalidUnconfirmed() ([]cipher.SHA256, error)
- func (vs *Visor) Run() error
- func (vs *Visor) Shutdown()
- func (vs *Visor) SignBlock(b coin.Block) coin.SignedBlock
- func (vs *Visor) UnconfirmedIncomingOutputs() (coin.UxArray, error)
- func (vs *Visor) UnconfirmedSpendingOutputs() (coin.UxArray, error)
Constants ¶
const ( // DebugLevel1 checks for extremely unlikely conditions (10e-40) DebugLevel1 = true // DebugLevel2 enable checks for impossible conditions DebugLevel2 = true // SigVerifyTheadNum signature verifycation goroutine number SigVerifyTheadNum = 4 )
const ( // Maximum supply of spo tokens MaxCoinSupply uint64 = 28e8 // 2800,000,000 million // Number of distribution addresses DistributionAddressesTotal uint64 = 280 DistributionAddressInitialBalance uint64 = MaxCoinSupply / DistributionAddressesTotal // Initial number of unlocked addresses InitialUnlockedCount uint64 = 25 // Number of addresses to unlock per unlock time interval UnlockAddressRate uint64 = 5 // Unlock time interval, measured in seconds // Once the InitialUnlockedCount is exhausted, // UnlockAddressRate addresses will be unlocked per UnlockTimeInterval UnlockTimeInterval uint64 = 60 * 60 * 24 * 365 // 1 year )
const ( // MaxDropletPrecision represents the decimal precision of droplets MaxDropletPrecision uint64 = 3 //DefaultMaxBlockSize is max block size DefaultMaxBlockSize int = 32 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func DefaultWalker ¶
DefaultWalker default blockchain walker
func DropletPrecisionCheck ¶
DropletPrecisionCheck checks if an amount of coins is valid given decimal place restrictions
func GetDistributionAddresses ¶
func GetDistributionAddresses() []string
Returns a copy of the hardcoded distribution addresses array. Each address has 10,000,000 coins. There are 280 addresses.
func GetLockedDistributionAddresses ¶
func GetLockedDistributionAddresses() []string
Returns distribution addresses that are locked, i.e. they have unspendable outputs
func GetUnlockedDistributionAddresses ¶
func GetUnlockedDistributionAddresses() []string
Returns distribution addresses that are unlocked, i.e. they have spendable outputs
func MaxDropletDivisor ¶
func MaxDropletDivisor() uint64
MaxDropletDivisor represents the modulus divisor when checking droplet precision rules.
func NewErrTxnViolatesHardConstraint ¶
NewErrTxnViolatesHardConstraint creates ErrTxnViolatesHardConstraint
func NewErrTxnViolatesSoftConstraint ¶
NewErrTxnViolatesSoftConstraint creates ErrTxnViolatesSoftConstraint
func ReadableOutputsToUxBalances ¶
func ReadableOutputsToUxBalances(ros ReadableOutputs) ([]wallet.UxBalance, error)
ReadableOutputsToUxBalances converts ReadableOutputs to []wallet.UxBalance
func ToAddresses ¶
func ToAddresses(addresses []cipher.Address) func(UnconfirmedTxn) bool
ToAddresses represents a filter that check if tx has output to the given addresses
func TransactionIsLocked ¶
Returns true if the transaction spends locked outputs
func TransactionToJSON ¶
func TransactionToJSON(tx coin.Transaction) (string, error)
TransactionToJSON convert transaction to json string TODO -- remove in favor of ReadableTransaction?
func VerifyBlockTxnConstraints ¶
func VerifyBlockTxnConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
VerifyBlockTxnConstraints returns an error if any "hard" constraints are violated. "hard" constraints are always enforced and if violated the transaction should not be included in any block and any block that includes such a transaction should be rejected. Checks:
- That the inputs to the transaction exist
- That the transaction does not create or destroy coins
- That the signatures on the transaction are valid
- That there are no duplicate ux inputs
- That there are no duplicate outputs
- That the transaction input and output coins do not overflow uint64
- That the transaction input hours do not overflow uint64
NOTE: Double spends are checked against the unspent output pool when querying for uxIn NOTE: output hours overflow is treated as a soft constraint for transactions inside of a block, due to a bug
which allowed some blocks to be published with overflowing output hours.
func VerifySingleTxnHardConstraints ¶
func VerifySingleTxnHardConstraints(txn coin.Transaction, head *coin.SignedBlock, uxIn coin.UxArray) error
VerifySingleTxnHardConstraints returns an error if any "hard" constraints are violated. "hard" constraints are always enforced and if violated the transaction should not be included in any block and any block that includes such a transaction should be rejected. Checks:
- That the inputs to the transaction exist
- That the transaction does not create or destroy coins
- That the signatures on the transaction are valid
- That there are no duplicate ux inputs
- That there are no duplicate outputs
- That the transaction input and output coins do not overflow uint64
- That the transaction input and output hours do not overflow uint64
NOTE: Double spends are checked against the unspent output pool when querying for uxIn
func VerifySingleTxnSoftConstraints ¶
func VerifySingleTxnSoftConstraints(txn coin.Transaction, headTime uint64, uxIn coin.UxArray, maxSize int) error
VerifySingleTxnSoftConstraints returns an error if any "soft" constraint are violated. "soft" constaints are enforced at the network and block publication level, but are not enforced at the blockchain level. Clients will not accept blocks that violate hard constraints, but will accept blocks that violate soft constraints. Checks:
- That the transaction size is not greater than the max block total transaction size
- That the transaction burn enough coin hours (the fee)
- That if that transaction does not spend from a locked distribution address
- That the transaction does not create outputs with a higher decimal precision than is allowed
Types ¶
type BlockListener ¶
BlockListener notify the register when new block is appended to the chain
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain maintains blockchain and provides apis for accessing the chain.
func NewBlockchain ¶
NewBlockchain use the walker go through the tree and update the head and unspent outputs.
func (*Blockchain) BindListener ¶
func (bc *Blockchain) BindListener(ls BlockListener)
BindListener register the listener to blockchain, when new block appended, the listener will be invoked.
func (*Blockchain) ExecuteBlockWithTx ¶
func (bc *Blockchain) ExecuteBlockWithTx(tx *bolt.Tx, sb *coin.SignedBlock) error
ExecuteBlockWithTx attempts to append block to blockchain with *bolt.Tx
func (*Blockchain) GetBlockByHash ¶
func (bc *Blockchain) GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
GetBlockByHash returns block of given hash
func (*Blockchain) GetBlockBySeq ¶
func (bc *Blockchain) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
GetBlockBySeq returns block of given seq
func (Blockchain) GetBlocks ¶
func (bc Blockchain) GetBlocks(start, end uint64) []coin.SignedBlock
GetBlocks return blocks whose seq are in the range of start and end.
func (*Blockchain) GetGenesisBlock ¶
func (bc *Blockchain) GetGenesisBlock() *coin.SignedBlock
GetGenesisBlock returns genesis block
func (Blockchain) GetLastBlocks ¶
func (bc Blockchain) GetLastBlocks(num uint64) []coin.SignedBlock
GetLastBlocks return the latest N blocks.
func (Blockchain) Head ¶
func (bc Blockchain) Head() (*coin.SignedBlock, error)
Head returns the most recent confirmed block
func (*Blockchain) HeadSeq ¶
func (bc *Blockchain) HeadSeq() uint64
HeadSeq returns the sequence of head block
func (Blockchain) Len ¶
func (bc Blockchain) Len() uint64
Len returns the length of current blockchain.
func (Blockchain) NewBlock ¶
func (bc Blockchain) NewBlock(txns coin.Transactions, currentTime uint64) (*coin.Block, error)
NewBlock creates a Block given an array of Transactions. Only hard constraints are applied to transactions in the block. The caller of this function should apply any additional soft constraints, and choose which transactions to place into the block.
func (*Blockchain) Notify ¶
func (bc *Blockchain) Notify(b coin.Block)
Notify notifies the listener the new block.
func (*Blockchain) Time ¶
func (bc *Blockchain) Time() uint64
Time returns time of last block used as system clock indepedent clock for coin hour calculations TODO: Deprecate
func (Blockchain) TransactionFee ¶
func (bc Blockchain) TransactionFee(t *coin.Transaction) (uint64, error)
TransactionFee calculates the current transaction fee in coinhours of a Transaction
func (*Blockchain) Unspent ¶
func (bc *Blockchain) Unspent() blockdb.UnspentPool
Unspent returns the unspent outputs pool
func (*Blockchain) UpdateDB ¶
func (bc *Blockchain) UpdateDB(f func(t *bolt.Tx) error) error
UpdateDB updates db with given func
func (Blockchain) VerifyBlockTxnConstraints ¶
func (bc Blockchain) VerifyBlockTxnConstraints(tx coin.Transaction) error
VerifyBlockTxnConstraints checks that the transaction does not violate hard constraints, for transactions that are already included in a block.
func (Blockchain) VerifySingleTxnAllConstraints ¶
func (bc Blockchain) VerifySingleTxnAllConstraints(tx coin.Transaction, maxSize int) error
VerifySingleTxnAllConstraints checks that the transaction does not violate hard or soft constraints, for transactions that are not included in a block. Hard constraints are checked before soft constraints.
func (Blockchain) VerifySingleTxnHardConstraints ¶
func (bc Blockchain) VerifySingleTxnHardConstraints(tx coin.Transaction) error
VerifySingleTxnHardConstraints checks that the transaction does not violate hard constraints. for transactions that are not included in a block.
type BlockchainMetadata ¶
type BlockchainMetadata struct {
// Most recent block's header
Head ReadableBlockHeader `json:"head"`
// Number of unspent outputs in the coin.Blockchain
Unspents uint64 `json:"unspents"`
// Number of known unconfirmed txns
Unconfirmed uint64 `json:"unconfirmed"`
}
BlockchainMetadata encapsulates useful information from the coin.Blockchain
func NewBlockchainMetadata ¶
func NewBlockchainMetadata(v *Visor) (*BlockchainMetadata, error)
NewBlockchainMetadata creates blockchain meta data
type BlockchainParser ¶
type BlockchainParser struct {
// contains filtered or unexported fields
}
BlockchainParser parses the blockchain and stores the data into historydb.
func NewBlockchainParser ¶
func NewBlockchainParser(hisDB *historydb.HistoryDB, bc *Blockchain, ops ...ParserOption) *BlockchainParser
NewBlockchainParser create and init the parser instance.
func (*BlockchainParser) FeedBlock ¶
func (bcp *BlockchainParser) FeedBlock(b coin.Block)
FeedBlock feeds block to the parser
func (*BlockchainParser) Run ¶
func (bcp *BlockchainParser) Run() error
Run starts blockchain parser
func (*BlockchainParser) Shutdown ¶
func (bcp *BlockchainParser) Shutdown()
Shutdown close the block parsing process.
type Blockchainer ¶
type Blockchainer interface {
GetGenesisBlock() *coin.SignedBlock
GetBlocks(start, end uint64) []coin.SignedBlock
GetLastBlocks(n uint64) []coin.SignedBlock
GetBlockByHash(hash cipher.SHA256) (*coin.SignedBlock, error)
GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
Unspent() blockdb.UnspentPool
Len() uint64
Head() (*coin.SignedBlock, error)
HeadSeq() uint64
Time() uint64
NewBlock(txns coin.Transactions, currentTime uint64) (*coin.Block, error)
ExecuteBlockWithTx(tx *bolt.Tx, sb *coin.SignedBlock) error
VerifyBlockTxnConstraints(tx coin.Transaction) error
VerifySingleTxnHardConstraints(tx coin.Transaction) error
VerifySingleTxnAllConstraints(tx coin.Transaction, maxSize int) error
TransactionFee(t *coin.Transaction) (uint64, error)
Notify(b coin.Block)
BindListener(bl BlockListener)
UpdateDB(f func(tx *bolt.Tx) error) error
}
Blockchainer is the interface that provides methods for accessing the blockchain data
type BuildInfo ¶
type BuildInfo struct {
Version string `json:"version"` // version number
Commit string `json:"commit"` // git commit id
Branch string `json:"branch"` // git branch name
}
BuildInfo represents the build info
type Config ¶
type Config struct {
// Is this the master blockchain
IsMaster bool
//Public key of blockchain authority
BlockchainPubkey cipher.PubKey
//Secret key of blockchain authority (if master)
BlockchainSeckey cipher.SecKey
// How often new blocks are created by the master, in seconds
BlockCreationInterval uint64
// How often an unconfirmed txn is checked against the blockchain
UnconfirmedCheckInterval time.Duration
// How long we'll hold onto an unconfirmed txn
UnconfirmedMaxAge time.Duration
// How often to check the unconfirmed pool for transactions that become valid
UnconfirmedRefreshRate time.Duration
// How often to remove transactions that become permanently invalid from the unconfirmed pool
UnconfirmedRemoveInvalidRate time.Duration
// How often to rebroadcast unconfirmed transactions
UnconfirmedResendPeriod time.Duration
// Maximum size of a block, in bytes.
MaxBlockSize int
// Where the blockchain is saved
BlockchainFile string
// Where the block signatures are saved
BlockSigsFile string
//address for genesis
GenesisAddress cipher.Address
// Genesis block sig
GenesisSignature cipher.Sig
// Genesis block timestamp
GenesisTimestamp uint64
// Number of coins in genesis block
GenesisCoinVolume uint64
// bolt db file path
DBPath string
// open bolt db read-only
DBReadOnly bool
// enable arbitrating mode
Arbitrating bool
// wallet directory
WalletDirectory string
// build info, including version, build time etc.
BuildInfo BuildInfo
// enables wallet API
EnableWalletAPI bool
// enables seed API
EnableSeedAPI bool
// wallet crypto type
WalletCryptoType wallet.CryptoType
}
Config configuration parameters for the Visor
func NewVisorConfig ¶
func NewVisorConfig() Config
NewVisorConfig put cap on block size, not on transactions/block Spo transactions are smaller than Bitcoin transactions so skycoin has a higher transactions per second for the same block size
type ErrTxnViolatesHardConstraint ¶
type ErrTxnViolatesHardConstraint struct {
Err error
}
ErrTxnViolatesHardConstraint is returned when a transaction violates hard constraints
func (ErrTxnViolatesHardConstraint) Error ¶
func (e ErrTxnViolatesHardConstraint) Error() string
type ErrTxnViolatesSoftConstraint ¶
type ErrTxnViolatesSoftConstraint struct {
Err error
}
ErrTxnViolatesSoftConstraint is returned when a transaction violates soft constraints
func (ErrTxnViolatesSoftConstraint) Error ¶
func (e ErrTxnViolatesSoftConstraint) Error() string
type Option ¶
type Option func(*Blockchain)
Option represents the option when creating the blockchain
type ParserOption ¶
type ParserOption func(*BlockchainParser)
ParserOption option type which will be used when creating parser instance
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
RPC is balance check and transaction injection separate wallets out of visor
func (*RPC) CreateAndSignTransaction ¶
func (rpc *RPC) CreateAndSignTransaction(wltID string, password []byte, vld wallet.Validator, unspent blockdb.UnspentGetter, headTime, coins uint64, dest cipher.Address) (*coin.Transaction, error)
CreateAndSignTransaction creates and sign transaction from wallet
func (*RPC) CreateAndSignTransactionAdvanced ¶
func (rpc *RPC) CreateAndSignTransactionAdvanced(params wallet.CreateTransactionParams, sv wallet.Validator, unspent blockdb.UnspentGetter, headTime uint64) (*coin.Transaction, []wallet.UxBalance, error)
CreateAndSignTransactionAdvanced creates and sign transaction from wallet
func (*RPC) CreateWallet ¶
func (rpc *RPC) CreateWallet(wltName string, options wallet.Options, bg wallet.BalanceGetter) (*wallet.Wallet, error)
CreateWallet creates new wallet
func (RPC) GetAddressTxns ¶
GetAddressTxns get address transactions
func (RPC) GetBlockBySeq ¶
GetBlockBySeq get block in depth
func (RPC) GetBlockchainMetadata ¶
func (rpc RPC) GetBlockchainMetadata(v *Visor) (*BlockchainMetadata, error)
GetBlockchainMetadata get blockchain meta data
func (RPC) GetBlocks ¶
func (rpc RPC) GetBlocks(v *Visor, start, end uint64) []coin.SignedBlock
GetBlocks gets blocks
func (*RPC) GetBuildInfo ¶
GetBuildInfo returns node build info, including version, build time, etc.
func (RPC) GetLastBlocks ¶
func (rpc RPC) GetLastBlocks(v *Visor, num uint64) []coin.SignedBlock
GetLastBlocks returns the last N blocks
func (RPC) GetTransaction ¶
GetTransaction gets transaction
func (RPC) GetUnconfirmedReceiving ¶
func (rpc RPC) GetUnconfirmedReceiving(v *Visor, addrs []cipher.Address) (coin.AddressUxOuts, error)
GetUnconfirmedReceiving returns unconfirmed
func (RPC) GetUnconfirmedSpends ¶
GetUnconfirmedSpends get unconfirmed spents
func (RPC) GetUnconfirmedTxns ¶
func (rpc RPC) GetUnconfirmedTxns(v *Visor, addresses []cipher.Address) []UnconfirmedTxn
GetUnconfirmedTxns gets unconfirmed transactions
func (RPC) GetUnspent ¶
func (rpc RPC) GetUnspent(v *Visor) blockdb.UnspentPool
GetUnspent gets unspent
func (*RPC) GetWalletAddresses ¶
GetWalletAddresses returns all addresses in given wallet
func (*RPC) GetWallets ¶
GetWallets returns all wallet
func (*RPC) NewAddresses ¶
NewAddresses generates new addresses in given wallet
func (*RPC) ReloadWallets ¶
ReloadWallets reloads all wallet from files
func (*RPC) UnloadWallet ¶
UnloadWallet removes the wallet of given id from wallet service.
func (*RPC) UpdateWalletLabel ¶
UpdateWalletLabel updates wallet label
type ReadableBlock ¶
type ReadableBlock struct {
Head ReadableBlockHeader `json:"header"`
Body ReadableBlockBody `json:"body"`
Size int `json:"size"`
}
ReadableBlock represents readable block
func NewReadableBlock ¶
func NewReadableBlock(b *coin.Block) (*ReadableBlock, error)
NewReadableBlock creates readable block
type ReadableBlockBody ¶
type ReadableBlockBody struct {
Transactions []ReadableTransaction `json:"txns"`
}
ReadableBlockBody represents readable block body
func NewReadableBlockBody ¶
func NewReadableBlockBody(b *coin.Block) (*ReadableBlockBody, error)
NewReadableBlockBody creates readable block body
type ReadableBlockHeader ¶
type ReadableBlockHeader struct {
BkSeq uint64 `json:"seq"`
BlockHash string `json:"block_hash"`
PreviousBlockHash string `json:"previous_block_hash"`
Time uint64 `json:"timestamp"`
Fee uint64 `json:"fee"`
Version uint32 `json:"version"`
BodyHash string `json:"tx_body_hash"`
}
ReadableBlockHeader represents the readable block header
func NewReadableBlockHeader ¶
func NewReadableBlockHeader(b *coin.BlockHeader) ReadableBlockHeader
NewReadableBlockHeader creates readable block header
type ReadableBlocks ¶
type ReadableBlocks struct {
Blocks []ReadableBlock `json:"blocks"`
}
ReadableBlocks an array of readable blocks.
func NewReadableBlocks ¶
func NewReadableBlocks(blocks []coin.SignedBlock) (*ReadableBlocks, error)
NewReadableBlocks converts []coin.SignedBlock to readable blocks
type ReadableOutput ¶
type ReadableOutput struct {
Hash string `json:"hash"`
Time uint64 `json:"time"`
BkSeq uint64 `json:"block_seq"`
SourceTransaction string `json:"src_tx"`
Address string `json:"address"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
CalculatedHours uint64 `json:"calculated_hours"`
}
ReadableOutput represents readable output
func NewReadableOutput ¶
func NewReadableOutput(headTime uint64, t coin.UxOut) (ReadableOutput, error)
NewReadableOutput creates readable output
type ReadableOutputSet ¶
type ReadableOutputSet struct {
// HeadOutputs are unspent outputs confirmed in the blockchain
HeadOutputs ReadableOutputs `json:"head_outputs"`
// IncomingOutputs are unspent outputs being spent in unconfirmed transactions
OutgoingOutputs ReadableOutputs `json:"outgoing_outputs"`
// IncomingOutputs are unspent outputs being created by unconfirmed transactions
IncomingOutputs ReadableOutputs `json:"incoming_outputs"`
}
ReadableOutputSet records unspent outputs in different status.
func (ReadableOutputSet) AggregateUnspentOutputs ¶
func (os ReadableOutputSet) AggregateUnspentOutputs() (map[string]uint64, error)
AggregateUnspentOutputs aggregate unspent output
func (ReadableOutputSet) ExpectedOutputs ¶
func (os ReadableOutputSet) ExpectedOutputs() ReadableOutputs
ExpectedOutputs adds IncomingOutputs to SpendableOutputs
func (ReadableOutputSet) SpendableOutputs ¶
func (os ReadableOutputSet) SpendableOutputs() ReadableOutputs
SpendableOutputs subtracts OutgoingOutputs from HeadOutputs
type ReadableOutputs ¶
type ReadableOutputs []ReadableOutput
ReadableOutputs slice of ReadableOutput provids method to calculate balance
func NewReadableOutputs ¶
func NewReadableOutputs(headTime uint64, uxs coin.UxArray) (ReadableOutputs, error)
NewReadableOutputs converts unspent outputs to readable output
type ReadableTransaction ¶
type ReadableTransaction struct {
Length uint32 `json:"length"`
Type uint8 `json:"type"`
Hash string `json:"txid"`
InnerHash string `json:"inner_hash"`
Timestamp uint64 `json:"timestamp,omitempty"`
Sigs []string `json:"sigs"`
In []string `json:"inputs"`
Out []ReadableTransactionOutput `json:"outputs"`
}
ReadableTransaction represents readable transaction
func NewGenesisReadableTransaction ¶
func NewGenesisReadableTransaction(t *Transaction) (*ReadableTransaction, error)
NewGenesisReadableTransaction creates genesis readable transaction
func NewReadableTransaction ¶
func NewReadableTransaction(t *Transaction) (*ReadableTransaction, error)
NewReadableTransaction creates readable transaction
type ReadableTransactionInput ¶
type ReadableTransactionInput struct {
Hash string `json:"uxid"`
Address string `json:"owner"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
}
ReadableTransactionInput readable transaction input
func NewReadableTransactionInput ¶
func NewReadableTransactionInput(uxID, ownerAddress string, coins, hours uint64) (*ReadableTransactionInput, error)
NewReadableTransactionInput creates readable transaction input
type ReadableTransactionOutput ¶
type ReadableTransactionOutput struct {
Hash string `json:"uxid"`
Address string `json:"dst"`
Coins string `json:"coins"`
Hours uint64 `json:"hours"`
}
ReadableTransactionOutput readable transaction output
func NewReadableTransactionOutput ¶
func NewReadableTransactionOutput(t *coin.TransactionOutput, txid cipher.SHA256) (*ReadableTransactionOutput, error)
NewReadableTransactionOutput creates readable transaction outputs
type ReadableUnconfirmedTxn ¶
type ReadableUnconfirmedTxn struct {
Txn ReadableTransaction `json:"transaction"`
Received time.Time `json:"received"`
Checked time.Time `json:"checked"`
Announced time.Time `json:"announced"`
IsValid bool `json:"is_valid"`
}
ReadableUnconfirmedTxn represents readable unconfirmed transaction
func NewReadableUnconfirmedTxn ¶
func NewReadableUnconfirmedTxn(unconfirmed *UnconfirmedTxn) (*ReadableUnconfirmedTxn, error)
NewReadableUnconfirmedTxn creates readable unconfirmed transaction
func NewReadableUnconfirmedTxns ¶
func NewReadableUnconfirmedTxns(txs []UnconfirmedTxn) ([]ReadableUnconfirmedTxn, error)
NewReadableUnconfirmedTxns converts []UnconfirmedTxn to []ReadableUnconfirmedTxn
type Richlist ¶
type Richlist []RichlistBalance
Richlist contains RichlistBalances
func NewRichlist ¶
NewRichlist create Richlist via unspent outputs map
func (Richlist) FilterAddresses ¶
FilterAddresses returns the richlist without addresses from the map
type RichlistBalance ¶
type RichlistBalance struct {
Address string `json:"address"`
Coins string `json:"coins"`
Locked bool `json:"locked"`
// contains filtered or unexported fields
}
RichlistBalance holds info an address balance holder
type Transaction ¶
type Transaction struct {
Txn coin.Transaction //`json:"txn"`
Status TransactionStatus //`json:"status"`
Time uint64 //`json:"time"`
Size int
}
Transaction wraps around coin.Transaction, tagged with its status. This allows us to include unconfirmed txns
type TransactionJSON ¶
type TransactionJSON struct {
Hash string `json:"hash"`
InnerHash string `json:"inner_hash"`
Sigs []string `json:"sigs"`
In []string `json:"in"`
Out []TransactionOutputJSON `json:"out"`
}
TransactionJSON represents transaction in json
type TransactionOutputJSON ¶
type TransactionOutputJSON struct {
Hash string `json:"hash"`
SourceTransaction string `json:"src_tx"`
Address string `json:"address"` // Address of receiver
Coins string `json:"coins"` // Number of coins
Hours uint64 `json:"hours"` // Coin hours
}
TransactionOutputJSON represents the transaction output json
func NewTxOutputJSON ¶
func NewTxOutputJSON(ux coin.TransactionOutput, srcTx cipher.SHA256) (*TransactionOutputJSON, error)
NewTxOutputJSON creates transaction output json
type TransactionResult ¶
type TransactionResult struct {
Status TransactionStatus `json:"status"`
Time uint64 `json:"time"`
Transaction ReadableTransaction `json:"txn"`
}
TransactionResult represents transaction result
func NewTransactionResult ¶
func NewTransactionResult(tx *Transaction) (*TransactionResult, error)
NewTransactionResult converts Transaction to TransactionResult
type TransactionResults ¶
type TransactionResults struct {
Txns []TransactionResult `json:"txns"`
}
TransactionResults array of transaction results
func NewTransactionResults ¶
func NewTransactionResults(txs []Transaction) (*TransactionResults, error)
NewTransactionResults converts []Transaction to []TransactionResults
type TransactionStatus ¶
type TransactionStatus struct {
Confirmed bool `json:"confirmed"`
// This txn is in the unconfirmed pool
Unconfirmed bool `json:"unconfirmed"`
// If confirmed, how many blocks deep in the chain it is. Will be at least
// 1 if confirmed.
Height uint64 `json:"height"`
// Execute block seq
BlockSeq uint64 `json:"block_seq"`
// We can't find anything about this txn. Be aware that the txn may be
// in someone else's unconfirmed pool, and if valid, it may become a
// confirmed txn in the future
Unknown bool `json:"unknown"`
}
TransactionStatus represents the transaction status
func NewConfirmedTransactionStatus ¶
func NewConfirmedTransactionStatus(height uint64, blockSeq uint64) TransactionStatus
NewConfirmedTransactionStatus creates confirmed transaction status
func NewUnconfirmedTransactionStatus ¶
func NewUnconfirmedTransactionStatus() TransactionStatus
NewUnconfirmedTransactionStatus creates unconfirmed transaction status
func NewUnknownTransactionStatus ¶
func NewUnknownTransactionStatus() TransactionStatus
NewUnknownTransactionStatus creates unknow transaction status
type TxFilter ¶
type TxFilter interface {
// Returns whether the transaction is matched
Match(*Transaction) bool
}
TxFilter transaction filter type
func AddrsFilter ¶
AddrsFilter collects all addresses related transactions.
func ConfirmedTxFilter ¶
ConfirmedTxFilter collects the transaction whose 'Confirmed' status matchs the parameter passed in.
type TxnUnspents ¶
TxnUnspents maps from coin.Transaction hash to its expected unspents. The unspents' Head can be different at execution time, but the Unspent's hash is fixed.
func (TxnUnspents) AllForAddress ¶
func (tus TxnUnspents) AllForAddress(a cipher.Address) coin.UxArray
AllForAddress returns all Unspents for a single address
type UnconfirmedTxn ¶
type UnconfirmedTxn struct {
Txn coin.Transaction
// Time the txn was last received
Received int64
// Time the txn was last checked against the blockchain
Checked int64
// Last time we announced this txn
Announced int64
// If this txn is valid
IsValid int8
}
UnconfirmedTxn unconfirmed transaction
func (*UnconfirmedTxn) Hash ¶
func (ut *UnconfirmedTxn) Hash() cipher.SHA256
Hash returns the coin.Transaction's hash
type UnconfirmedTxnPool ¶
type UnconfirmedTxnPool struct {
// contains filtered or unexported fields
}
UnconfirmedTxnPool manages unconfirmed transactions
func NewUnconfirmedTxnPool ¶
func NewUnconfirmedTxnPool(db *bolt.DB) *UnconfirmedTxnPool
NewUnconfirmedTxnPool creates an UnconfirmedTxnPool instance
func (*UnconfirmedTxnPool) FilterKnown ¶
func (utp *UnconfirmedTxnPool) FilterKnown(txns []cipher.SHA256) []cipher.SHA256
FilterKnown returns txn hashes with known ones removed
func (*UnconfirmedTxnPool) ForEach ¶
func (utp *UnconfirmedTxnPool) ForEach(f func(cipher.SHA256, *UnconfirmedTxn) error) error
ForEach iterate the pool with given callback function,
func (*UnconfirmedTxnPool) Get ¶
func (utp *UnconfirmedTxnPool) Get(key cipher.SHA256) (*UnconfirmedTxn, bool)
Get returns the unconfirmed transaction of given tx hash.
func (*UnconfirmedTxnPool) GetIncomingOutputs ¶
func (utp *UnconfirmedTxnPool) GetIncomingOutputs(bh coin.BlockHeader) coin.UxArray
GetIncomingOutputs returns all predicted incoming outputs.
func (*UnconfirmedTxnPool) GetKnown ¶
func (utp *UnconfirmedTxnPool) GetKnown(txns []cipher.SHA256) coin.Transactions
GetKnown returns all known coin.Transactions from the pool, given hashes to select
func (*UnconfirmedTxnPool) GetSpendingOutputs ¶
func (utp *UnconfirmedTxnPool) GetSpendingOutputs(bcUnspent blockdb.UnspentPool) (coin.UxArray, error)
GetSpendingOutputs returns all spending outputs in unconfirmed tx pool.
func (*UnconfirmedTxnPool) GetTxHashes ¶
func (utp *UnconfirmedTxnPool) GetTxHashes(filter func(tx UnconfirmedTxn) bool) (hashes []cipher.SHA256)
GetTxHashes returns transaction hashes that can pass the filter
func (*UnconfirmedTxnPool) GetTxns ¶
func (utp *UnconfirmedTxnPool) GetTxns(filter func(tx UnconfirmedTxn) bool) (txns []UnconfirmedTxn)
GetTxns returns all transactions that can pass the filter
func (*UnconfirmedTxnPool) GetUnspentsOfAddr ¶
func (utp *UnconfirmedTxnPool) GetUnspentsOfAddr(addr cipher.Address) coin.UxArray
GetUnspentsOfAddr returns unspent outputs of given address in unspent tx pool
func (*UnconfirmedTxnPool) InjectTransaction ¶
func (utp *UnconfirmedTxnPool) InjectTransaction(bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
InjectTransaction adds a coin.Transaction to the pool, or updates an existing one's timestamps Returns an error if txn is invalid, and whether the transaction already existed in the pool. If the transaction violates hard constraints, it is rejected. Soft constraints violations mark a txn as invalid, but the txn is inserted. The soft violation is returned.
func (*UnconfirmedTxnPool) Len ¶
func (utp *UnconfirmedTxnPool) Len() int
Len returns the number of unconfirmed transactions
func (*UnconfirmedTxnPool) RawTxns ¶
func (utp *UnconfirmedTxnPool) RawTxns() coin.Transactions
RawTxns returns underlying coin.Transactions
func (*UnconfirmedTxnPool) RecvOfAddresses ¶
func (utp *UnconfirmedTxnPool) RecvOfAddresses(bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
RecvOfAddresses returns unconfirmed receiving uxouts of addresses
func (*UnconfirmedTxnPool) Refresh ¶
func (utp *UnconfirmedTxnPool) Refresh(bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
Refresh checks all unconfirmed txns against the blockchain. If the transaction becomes invalid it is marked invalid. If the transaction becomes valid it is marked valid and is returned to the caller.
func (*UnconfirmedTxnPool) RemoveInvalid ¶
func (utp *UnconfirmedTxnPool) RemoveInvalid(bc Blockchainer) ([]cipher.SHA256, error)
RemoveInvalid checks all unconfirmed txns against the blockchain. If a transaction violates hard constraints it is removed from the pool. The transactions that were removed are returned.
func (*UnconfirmedTxnPool) RemoveTransactions ¶
func (utp *UnconfirmedTxnPool) RemoveTransactions(txns []cipher.SHA256) error
RemoveTransactions removes confirmed txns from the pool
func (*UnconfirmedTxnPool) RemoveTransactionsWithTx ¶
func (utp *UnconfirmedTxnPool) RemoveTransactionsWithTx(tx *bolt.Tx, txns []cipher.SHA256)
RemoveTransactionsWithTx remove transactions with bolt.Tx
func (*UnconfirmedTxnPool) SetAnnounced ¶
SetAnnounced updates announced time of specific tx
func (*UnconfirmedTxnPool) SpendsOfAddresses ¶
func (utp *UnconfirmedTxnPool) SpendsOfAddresses(addrs []cipher.Address, unspent blockdb.UnspentGetter) (coin.AddressUxOuts, error)
SpendsOfAddresses returns all unconfirmed coin.UxOut spends of addresses Looks at all inputs for unconfirmed txns, gets their source UxOut from the blockchain's unspent pool, and returns as coin.AddressUxOuts
type UnconfirmedTxnPooler ¶
type UnconfirmedTxnPooler interface {
SetAnnounced(hash cipher.SHA256, t time.Time) error
InjectTransaction(bc Blockchainer, t coin.Transaction, maxSize int) (bool, *ErrTxnViolatesSoftConstraint, error)
RawTxns() coin.Transactions
RemoveTransactions(txns []cipher.SHA256) error
RemoveTransactionsWithTx(tx *bolt.Tx, txns []cipher.SHA256)
Refresh(bc Blockchainer, maxBlockSize int) ([]cipher.SHA256, error)
RemoveInvalid(bc Blockchainer) ([]cipher.SHA256, error)
FilterKnown(txns []cipher.SHA256) []cipher.SHA256
GetKnown(txns []cipher.SHA256) coin.Transactions
RecvOfAddresses(bh coin.BlockHeader, addrs []cipher.Address) (coin.AddressUxOuts, error)
SpendsOfAddresses(addrs []cipher.Address, unspent blockdb.UnspentGetter) (coin.AddressUxOuts, error)
GetSpendingOutputs(unspent blockdb.UnspentPool) (coin.UxArray, error)
GetIncomingOutputs(bh coin.BlockHeader) coin.UxArray
Get(hash cipher.SHA256) (*UnconfirmedTxn, bool)
GetTxns(filter func(tx UnconfirmedTxn) bool) []UnconfirmedTxn
GetTxHashes(filter func(tx UnconfirmedTxn) bool) []cipher.SHA256
ForEach(f func(cipher.SHA256, *UnconfirmedTxn) error) error
GetUnspentsOfAddr(addr cipher.Address) coin.UxArray
Len() int
}
UnconfirmedTxnPooler is the interface that provides methods for accessing the unconfirmed transaction pool
type UnspentGetFunc ¶
UnspentGetFunc callback function for querying unspent output of given hash
type Visor ¶
type Visor struct {
Config Config
// Unconfirmed transactions, held for relay until we get block confirmation
Unconfirmed UnconfirmedTxnPooler
Blockchain Blockchainer
Wallets *wallet.Service
StartedAt time.Time
// contains filtered or unexported fields
}
Visor manages the Blockchain as both a Master and a Normal
func (*Visor) AddressBalance ¶
AddressBalance computes the total balance for cipher.Addresses and their coin.UxOuts
func (*Visor) CreateAndExecuteBlock ¶
func (vs *Visor) CreateAndExecuteBlock() (coin.SignedBlock, error)
CreateAndExecuteBlock creates a SignedBlock from pending transactions and executes it
func (*Visor) CreateBlock ¶
func (vs *Visor) CreateBlock(when uint64) (coin.SignedBlock, error)
CreateBlock creates a SignedBlock from pending transactions
func (*Visor) CreateWallet ¶
CreateWallet creates wallet and scans ahead N addresses to look for a none-empty balance
func (*Visor) ExecuteSignedBlock ¶
func (vs *Visor) ExecuteSignedBlock(b coin.SignedBlock) error
ExecuteSignedBlock adds a block to the blockchain, or returns error. Blocks must be executed in sequence, and be signed by the master server
func (*Visor) GenesisPreconditions ¶
func (vs *Visor) GenesisPreconditions()
GenesisPreconditions panics if conditions for genesis block are not met
func (Visor) GetAddrUxOuts ¶
GetAddrUxOuts gets all the address affected UxOuts.
func (*Visor) GetAddressTxns ¶
func (vs *Visor) GetAddressTxns(a cipher.Address) ([]Transaction, error)
GetAddressTxns returns the Transactions whose unspents give coins to a cipher.Address. This includes unconfirmed txns' predicted unspents.
func (*Visor) GetAllUnconfirmedTxns ¶
func (vs *Visor) GetAllUnconfirmedTxns() []UnconfirmedTxn
GetAllUnconfirmedTxns returns all unconfirmed transactions
func (*Visor) GetAllValidUnconfirmedTxHashes ¶
GetAllValidUnconfirmedTxHashes returns all valid unconfirmed transaction hashes
func (Visor) GetBalanceOfAddrs ¶
GetBalanceOfAddrs returns balance pairs of given addreses
func (*Visor) GetBlock ¶
func (vs *Visor) GetBlock(seq uint64) (*coin.SignedBlock, error)
GetBlock returns a copy of the block at seq. Returns error if seq out of range Move to blockdb
func (*Visor) GetBlockByHash ¶
GetBlockByHash get block of specific hash header, return nil on not found.
func (*Visor) GetBlockBySeq ¶
func (vs *Visor) GetBlockBySeq(seq uint64) (*coin.SignedBlock, error)
GetBlockBySeq get block of speicific seq, return nil on not found.
func (*Visor) GetBlockchainMetadata ¶
func (vs *Visor) GetBlockchainMetadata() (*BlockchainMetadata, error)
GetBlockchainMetadata returns descriptive Blockchain information
func (*Visor) GetBlocks ¶
func (vs *Visor) GetBlocks(start, end uint64) []coin.SignedBlock
GetBlocks returns multiple blocks between start and end (not including end). Returns empty slice if unable to fulfill request, it does not return nil. move to blockdb
func (Visor) GetHeadBlock ¶
func (vs Visor) GetHeadBlock() (*coin.SignedBlock, error)
GetHeadBlock gets head block.
func (*Visor) GetLastBlocks ¶
func (vs *Visor) GetLastBlocks(num uint64) []coin.SignedBlock
GetLastBlocks returns last N blocks
func (*Visor) GetSignedBlocksSince ¶
func (vs *Visor) GetSignedBlocksSince(seq, ct uint64) ([]coin.SignedBlock, error)
GetSignedBlocksSince returns signed blocks in an inclusive range of [seq+1, seq+ct]
func (*Visor) GetTransaction ¶
func (vs *Visor) GetTransaction(txHash cipher.SHA256) (*Transaction, error)
GetTransaction returns a Transaction by hash.
func (*Visor) GetTransactions ¶
func (vs *Visor) GetTransactions(flts ...TxFilter) ([]Transaction, error)
GetTransactions returns transactions that can pass the filters. If any 'AddrsFilter' exist, call vs.getTransactionsOfAddrs, cause there's an address index of transactions in db which, having address as key and transaction hashes as value. If no filters is provided, returns all transactions.
func (*Visor) GetUnconfirmedTxns ¶
func (vs *Visor) GetUnconfirmedTxns(filter func(UnconfirmedTxn) bool) []UnconfirmedTxn
GetUnconfirmedTxns gets all confirmed transactions of specific addresses
func (*Visor) GetUnspentOutputs ¶
GetUnspentOutputs makes local copy and update when block header changes update should lock isolate effect of threading call .Array() to get []UxOut array
func (Visor) GetUxOutByID ¶
GetUxOutByID gets UxOut by hash id.
func (*Visor) HeadBkSeq ¶
HeadBkSeq returns the highest BkSeq we know, returns -1 if the chain is empty
func (*Visor) InjectTransaction ¶
func (vs *Visor) InjectTransaction(txn coin.Transaction) (bool, *ErrTxnViolatesSoftConstraint, error)
InjectTransaction records a coin.Transaction to the UnconfirmedTxnPool if the txn is not already in the blockchain. The bool return value is whether or not the transaction was already in the pool. If the transaction violates hard constraints, it is rejected, and error will not be nil. If the transaction only violates soft constraints, it is still injected, and the soft constraint violation is returned.
func (*Visor) InjectTransactionStrict ¶
func (vs *Visor) InjectTransactionStrict(txn coin.Transaction) (bool, error)
InjectTransactionStrict records a coin.Transaction to the UnconfirmedTxnPool if the txn is not already in the blockchain. The bool return value is whether or not the transaction was already in the pool. If the transaction violates hard or soft constraints, it is rejected, and error will not be nil.
func (*Visor) RefreshUnconfirmed ¶
RefreshUnconfirmed checks unconfirmed txns against the blockchain and returns all transaction that turn to valid.
func (*Visor) RemoveInvalidUnconfirmed ¶
RemoveInvalidUnconfirmed removes transactions that become permanently invalid (by violating hard constraints) from the pool. Returns the transaction hashes that were removed.
func (*Visor) SignBlock ¶
func (vs *Visor) SignBlock(b coin.Block) coin.SignedBlock
SignBlock signs a block for master. Will panic if anything is invalid
func (*Visor) UnconfirmedIncomingOutputs ¶
UnconfirmedIncomingOutputs returns all predicted outputs that are in pending tx pool