Documentation ¶
Overview ¶
Copyright (c) 2018-2020. The asimov developers Copyright (c) 2013-2017 The btcsuite developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Copyright (c) 2013-2017 The btcsuite developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Copyright (c) 2018-2020. The asimov developers Copyright (c) 2013-2017 The btcsuite developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Index ¶
- Constants
- Variables
- func AppDataDir(appName string, roaming bool) string
- func DecodeAddress(addr string) (common.IAddress, error)
- func GenInputHash(msgTx *protos.MsgTx) []byte
- func GetBlockPair(db database.Transactor, hash *common.Hash) (block *Block, vblock *VBlock, err error)
- func HomeDir() string
- func IsMintOrCreateInput(in *protos.TxIn) bool
- func LoadBlockFromFile(file string) (*protos.MsgBlock, error)
- func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []string) (cert, key []byte, err error)
- type AssetsList
- type Block
- func (b *Block) Bytes() ([]byte, error)
- func (b *Block) GetBalance(address common.Address) *txo.UtxoMap
- func (b *Block) Hash() *common.Hash
- func (b *Block) Height() int32
- func (b *Block) IsSigned() bool
- func (b *Block) MsgBlock() *protos.MsgBlock
- func (b *Block) PutBalance(address common.Address, balance *txo.UtxoMap)
- func (b *Block) Round() uint32
- func (b *Block) SetHeight(height int32)
- func (b *Block) Signs() []*BlockSign
- func (b *Block) Transactions() []*Tx
- func (b *Block) Tx(txNum int) (*Tx, error)
- func (b *Block) TxHash(txNum int) (*common.Hash, error)
- func (b *Block) TxLoc() ([]protos.TxLoc, error)
- type BlockSign
- type MissVBlockError
- type OutOfRangeError
- type Tx
- type VBlock
- func (b *VBlock) Bytes() ([]byte, error)
- func (b *VBlock) Hash() *common.Hash
- func (b *VBlock) MsgVBlock() *protos.MsgVBlock
- func (b *VBlock) Transactions() []*Tx
- func (b *VBlock) Tx(txNum int) (*Tx, error)
- func (b *VBlock) TxHash(txNum int) (*common.Hash, error)
- func (b *VBlock) TxLoc() ([]protos.TxLoc, error)
Constants ¶
const ( //unknown, TxTypeUnknown int = 0 //unsupported type, illegal tx type. TxTypeUnsupport int = 1 // generated by vm, it happens when transferring coin in contract executions. TxTypeVM int = 2 //standard tx that generated by wallet. TxTypeNormal int = 4 )
const TransferCreationIdx = math.MaxUint32 - 1
const TransferMintIdx = math.MaxUint32 - 2
const TxIndexUnknown = -1
TxIndexUnknown is the value returned for a transaction index that is unknown. This is typically because the transaction has not been inserted into a block yet.
Variables ¶
var AsimovAsset = protos.Asset{}
Asimov coin asset
Functions ¶
func AppDataDir ¶
AppDataDir returns an operating system specific directory to be used for storing application data for an application.
The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.
The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.
Example results:
dir := AppDataDir("myapp", false) POSIX (Linux/BSD): ~/.myapp Mac OS: $HOME/Library/Application Support/Myapp Windows: %LOCALAPPDATA%\Myapp Plan 9: $home/myapp
func DecodeAddress ¶
DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.
The bitcoin network the address is associated with is extracted if possible. When the address does not encode the network, such as in the case of a raw public key, the address will be associated with the passed defaultNet.
func GenInputHash ¶
GenInputHash generates hash from txIn.PreviousOutPoint.Hash and txIn.PreviousOutPoint.Index
func GetBlockPair ¶
func GetBlockPair(db database.Transactor, hash *common.Hash) (block *Block, vblock *VBlock, err error)
GetBlockPair returns a new instance of an asimov block
func IsMintOrCreateInput ¶
IsMintOrCreateInput returns operate type of input, mint or create
func LoadBlockFromFile ¶
LoadBlockFromFile decodes a block from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the block
func NewTLSCertPair ¶
func NewTLSCertPair(organization string, validUntil time.Time, extraHosts []string) (cert, key []byte, err error)
NewTLSCertPair returns a new PEM-encoded x.509 certificate pair based on a 521-bit ECDSA private key. The machine's local interface addresses and all variants of IPv4 and IPv6 localhost are included as valid IP addresses.
Types ¶
type AssetsList ¶
assetList defines o list of asset
func (AssetsList) Len ¶
func (al AssetsList) Len() int
func (AssetsList) Less ¶
func (al AssetsList) Less(i, j int) bool
func (AssetsList) Swap ¶
func (al AssetsList) Swap(i, j int)
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block defines a bitcoin block that provides easier and more efficient manipulation of raw blocks. It also memoizes hashes for the block and its transactions on their first access so subsequent accesses don't have to repeat the relatively expensive hashing operations.
func NewBlock ¶
NewBlock returns a new instance of an asimov block given an underlying protos.MsgBlock. See Block.
func NewBlockFromBlockAndBytes ¶
NewBlockFromBlockAndBytes returns a new instance of a flow block given an underlying protos.MsgBlock and the serialized bytes for it. See Block.
func NewBlockFromBytes ¶
NewBlockFromBytes returns a new instance of a flow block given the serialized bytes. See Block.
func (*Block) Bytes ¶
Bytes returns the serialized bytes for the Block. This is equivalent to calling Serialize on the underlying protos.MsgBlock, however it caches the result so subsequent calls are more efficient.
func (*Block) GetBalance ¶
GetBalance returns balance of target address
func (*Block) Hash ¶
Hash returns the block identifier hash for the Block. This is equivalent to calling BlockHash on the underlying protos.MsgBlock, however it caches the result so subsequent calls are more efficient.
func (*Block) Height ¶
Round returns the saved height of the block in the block chain. This value will be BlockHeightUnknown if it hasn't already explicitly been set.
func (*Block) PutBalance ¶
PutBalance puts utxo of target address into cache
func (*Block) Transactions ¶
Transactions returns a slice of wrapped transactions (vvsutil.Tx) for all transactions in the Block. This is nearly equivalent to accessing the raw transactions (protos.MsgTx) in the underlying protos.MsgBlock, however it instead provides easy access to wrapped versions (vvsutil.Tx) of them.
func (*Block) Tx ¶
Tx returns a wrapped transaction (vvsutil.Tx) for the transaction at the specified index in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is nearly equivalent to accessing the raw transaction (protos.MsgTx) from the underlying protos.MsgBlock, however the wrapped transaction has some helpful properties such as caching the hash so subsequent calls are more efficient.
func (*Block) TxHash ¶
TxHash returns the hash for the requested transaction number in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is equivalent to calling TxHash on the underlying protos.MsgTx, however it caches the result so subsequent calls are more efficient.
type BlockSign ¶
type BlockSign struct { MsgSign *protos.MsgBlockSign // contains filtered or unexported fields }
BlockSign stores the signature hashes of msgBlock
func NewBlockSign ¶
func NewBlockSign(msgTx *protos.MsgBlockSign) *BlockSign
NewBlockSign sets MsgBlockSign into BlockSign
type MissVBlockError ¶
type MissVBlockError string
MissVBlockError describes an error due to accessing an element that is out of range.
func (MissVBlockError) Error ¶
func (e MissVBlockError) Error() string
Error satisfies the error interface and prints human-readable errors.
type OutOfRangeError ¶
type OutOfRangeError string
OutOfRangeError describes an error due to accessing an element that is out of range.
func (OutOfRangeError) Error ¶
func (e OutOfRangeError) Error() string
Error satisfies the error interface and prints human-readable errors.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx defines a bitcoin transaction that provides easier and more efficient manipulation of raw transactions. It also memorizes the hash for the transaction on its first access so subsequent accesses don't have to repeat the relatively expensive hashing operations.
func MergeTxVtx ¶
merge normal tx and virtual tx into a single list, to match the order of stxo set. the virtual tx will follow the parent normal tx(that tx contains contract execution and generates virtual tx) for ex: tx1, tx2, tx3, tx4 vtx2,vtx2-2, vtx3 ---> tx1, tx2, vtx2, vtx2-2, tx3, vtx3, tx4
func NewTx ¶
NewTx returns a new instance of a bitcoin transaction given an underlying protos.MsgTx. See Tx.
func NewTxFromBytes ¶
NewTxFromBytes returns a new instance of a bitcoin transaction given the serialized bytes. See Tx.
func NewTxFromReader ¶
NewTxFromReader returns a new instance of a bitcoin transaction given a Reader to deserialize the transaction. See Tx.
func (*Tx) GetInputHash ¶
GetInputHash returns hash of input from transaction
func (*Tx) Hash ¶
Hash returns the hash of the transaction. This is equivalent to calling TxHash on the underlying protos.MsgTx, however it caches the result so subsequent calls are more efficient.
func (*Tx) Index ¶
Index returns the saved index of the transaction within a block. This value will be TxIndexUnknown if it hasn't already explicitly been set.
type VBlock ¶
type VBlock struct {
// contains filtered or unexported fields
}
VBlock defines an asimov virtual block that provides easier and more efficient manipulation of raw virtual blocks. It also memorizes hashes for the virtual block and its virtual transactions on their first access so subsequent accesses don't have to repeat the relatively expensive hashing operations.
func NewVBlock ¶
NewVBlock returns a new instance of an asimov block given an underlying protos.MsgVBlock. See VBlock.
func NewVBlockFromBytes ¶
NewVBlockFromBytes returns a new instance of an asimov block given the serialized bytes. See VBlock.
func (*VBlock) Bytes ¶
Bytes returns the serialized bytes for the Block. This is equivalent to calling Serialize on the underlying protos.MsgBlock, however it caches the result so subsequent calls are more efficient.
func (*VBlock) Hash ¶
Hash returns the block identifier hash for the Block. This is equivalent to calling BlockHash on the underlying protos.MsgBlock, however it caches the result so subsequent calls are more efficient.
func (*VBlock) Transactions ¶
Transactions returns a slice of wrapped transactions (vvsutil.Tx) for all transactions in the Block. This is nearly equivalent to accessing the raw transactions (protos.MsgTx) in the underlying protos.MsgBlock, however it instead provides easy access to wrapped versions (vvsutil.Tx) of them.
func (*VBlock) Tx ¶
Tx returns a wrapped transaction (vvsutil.Tx) for the transaction at the specified index in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is nearly equivalent to accessing the raw transaction (protos.MsgTx) from the underlying protos.MsgBlock, however the wrapped transaction has some helpful properties such as caching the hash so subsequent calls are more efficient.
func (*VBlock) TxHash ¶
TxHash returns the hash for the requested transaction number in the Block. The supplied index is 0 based. That is to say, the first transaction in the block is txNum 0. This is equivalent to calling TxHash on the underlying protos.MsgTx, however it caches the result so subsequent calls are more efficient.