Documentation ¶
Index ¶
- func IntToHex(num int64) []byte
- type BlockByte
- type BlockChain
- func (bc *BlockChain) AddBlock(Transactions []*Transaction)
- func (bc *BlockChain) Balance(address string) []TXOutput
- func (bc *BlockChain) FindIsSpendableOutputs(txid []byte, pos int) bool
- func (bc *BlockChain) FindSpendableOutputs(address string, amount int) (int, map[string][]int)
- func (bc *BlockChain) FindTransaction(txid []byte) (*Transaction, error)
- func (bc *BlockChain) FindTransactionList(txid []byte) ([]Transaction, error)
- func (bc *BlockChain) FindTransactionNext(txid []byte) (*Transaction, error)
- func (bc *BlockChain) FindUTXO(address string) []TXOutput
- func (bc *BlockChain) FindUnspentTransactions(address string) []Transaction
- func (bc *BlockChain) GetBlockAll() []BlockByte
- func (bc *BlockChain) GetValue(key []byte) []byte
- func (bc *BlockChain) Iterator() *BlockChainIterator
- func (bc *BlockChain) MineBlock(transactions []*Transaction)
- func (bc *BlockChain) SetBlockAll(bs []BlockByte)
- func (bc *BlockChain) SetValue(key, value []byte) error
- func (bc *BlockChain) Traceability(address string) []Transaction
- func (bc *BlockChain) TransactionList() []Transaction
- func (bc *BlockChain) Users() []string
- func (bc *BlockChain) Version() int
- type BlockChainIterator
- type BlockData
- type ProofOfWork
- type TXInput
- type TXOutput
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockChain ¶
func (*BlockChain) FindIsSpendableOutputs ¶
func (bc *BlockChain) FindIsSpendableOutputs(txid []byte, pos int) bool
查找交易中 UTXO
func (*BlockChain) FindSpendableOutputs ¶
查找交易中 至少amount的 UTXO
func (*BlockChain) FindTransaction ¶
func (bc *BlockChain) FindTransaction(txid []byte) (*Transaction, error)
func (*BlockChain) FindTransactionList ¶
func (bc *BlockChain) FindTransactionList(txid []byte) ([]Transaction, error)
func (*BlockChain) FindTransactionNext ¶
func (bc *BlockChain) FindTransactionNext(txid []byte) (*Transaction, error)
寻找交易是否被引用
func (*BlockChain) FindUnspentTransactions ¶
func (bc *BlockChain) FindUnspentTransactions(address string) []Transaction
找到相关的交易
func (*BlockChain) GetValue ¶
func (bc *BlockChain) GetValue(key []byte) []byte
func (*BlockChain) Iterator ¶
func (bc *BlockChain) Iterator() *BlockChainIterator
func (*BlockChain) MineBlock ¶
func (bc *BlockChain) MineBlock(transactions []*Transaction)
func (*BlockChain) SetBlockAll ¶
func (bc *BlockChain) SetBlockAll(bs []BlockByte)
func (*BlockChain) SetValue ¶
func (bc *BlockChain) SetValue(key, value []byte) error
func (*BlockChain) Traceability ¶
func (bc *BlockChain) Traceability(address string) []Transaction
交易溯源
type BlockChainIterator ¶
type BlockChainIterator struct {
// contains filtered or unexported fields
}
区块链读取数据 迭代器
func (*BlockChainIterator) Next ¶
func (i *BlockChainIterator) Next() *BlockData
type BlockData ¶
type BlockData struct { Timestamp int64 Transactions []*Transaction PrevBlockHash []byte Hash []byte Nonce int }
func (*BlockData) HashTransactions ¶
type ProofOfWork ¶
type ProofOfWork struct { BlockData *BlockData // contains filtered or unexported fields }
func NewProofOfWork ¶
func NewProofOfWork(b *BlockData) *ProofOfWork
func (*ProofOfWork) Validate ¶
func (pow *ProofOfWork) Validate() bool
type TXInput ¶
type TXInput struct { Txid []byte //交易ID, 一个交易输入引用了之前一笔交易的一个输出, ID 表明是之前哪笔交易 Vout int //输出索引 ScriptSig string }
交易输入
func (*TXInput) CanUnlockOutputWith ¶
验证输入持有者
type Transaction ¶
type Transaction struct { ID []byte //ID Vin []TXInput //输入 Vout []TXOutput //输出 Data string //交易数据 }
交易体
func NewUTXOTransaction ¶
func NewUTXOTransaction(from, to, data string, amount int, bc *BlockChain) (*Transaction, error)
货币交易
func NewUTxIdTransaction ¶
func NewUTxIdTransaction(from, to, data string, txid []byte, bc *BlockChain) (*Transaction, error)
通过Txid指定交易
Click to show internal directories.
Click to hide internal directories.