Documentation ¶
Index ¶
- Constants
- func HashPublicKey(publicKey []byte) []byte
- func NewProofOfWork(block *Block) *proofOfWork
- type Block
- type Blockchain
- func (blockchain *Blockchain) AddBlock(block *Block)
- func (blockchain *Blockchain) CloseDB()
- func (blockchain *Blockchain) FindTransaction(ID []byte) (Transaction, error)
- func (blockchain *Blockchain) FindUnspentTransactionOutputs() map[string]TransactionOutputSet
- func (blockchain *Blockchain) GetBestHeight() int
- func (blockchain *Blockchain) GetBlock(blockHash []byte) (Block, error)
- func (blockchain *Blockchain) GetBlockHashes() [][]byte
- func (blockchain *Blockchain) Iterator() *BlockchainIterator
- func (blockchain *Blockchain) MineBlock(transactions []*Transaction) *Block
- func (blockchain *Blockchain) SignTransaction(transaction *Transaction, privateKey ecdsa.PrivateKey)
- func (blockchain *Blockchain) VerifyTransaction(transaction *Transaction) bool
- type BlockchainIterator
- type Transaction
- func (transaction Transaction) IsCoinbase() bool
- func (transaction *Transaction) Serialize() []byte
- func (transaction *Transaction) Sign(privateKey ecdsa.PrivateKey, previousTransactions map[string]Transaction)
- func (transaction *Transaction) TrimmedCopy() Transaction
- func (transaction *Transaction) Verify(previousTransactions map[string]Transaction) bool
- type TransactionInput
- type TransactionOutput
- type TransactionOutputSet
- type UnspentTransactionOutputSet
- func (unspentTransactionOutputSet UnspentTransactionOutputSet) CountTransactions() int
- func (unspentTransactionOutputSet UnspentTransactionOutputSet) FindSpendableOutputs(publicKeyHash []byte, amount int) (int, map[string][]int)
- func (unspentTransactionOutputSet UnspentTransactionOutputSet) FindUnspentTransactionOutputs(publicKeyHash []byte) []TransactionOutput
- func (unspentTransactionOutputSet UnspentTransactionOutputSet) Reindex()
- func (unspentTransactionOutputSet UnspentTransactionOutputSet) Update(block *Block)
- type Wallet
- type Wallets
Constants ¶
View Source
const (
AddressChecksumLength = 4
)
Variables ¶
This section is empty.
Functions ¶
func HashPublicKey ¶
func NewProofOfWork ¶
func NewProofOfWork(block *Block) *proofOfWork
Types ¶
type Block ¶
type Block struct { Timestamp int64 Transactions []*Transaction PreviousHash []byte Hash []byte Nonce int Height int }
func DeserializeBlock ¶
func NewBlock ¶
func NewBlock(transactions []*Transaction, previousHash []byte, height int) *Block
TODO: data [string] might not be applicable
func NewGenesisBlock ¶
func NewGenesisBlock(coinbase *Transaction) *Block
func (*Block) HashTransactions ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func NewBlockchain ¶
func NewBlockchain(nodeID string) *Blockchain
func (*Blockchain) AddBlock ¶
func (blockchain *Blockchain) AddBlock(block *Block)
func (*Blockchain) CloseDB ¶
func (blockchain *Blockchain) CloseDB()
func (*Blockchain) FindTransaction ¶
func (blockchain *Blockchain) FindTransaction(ID []byte) (Transaction, error)
func (*Blockchain) FindUnspentTransactionOutputs ¶
func (blockchain *Blockchain) FindUnspentTransactionOutputs() map[string]TransactionOutputSet
func (*Blockchain) GetBestHeight ¶
func (blockchain *Blockchain) GetBestHeight() int
func (*Blockchain) GetBlock ¶
func (blockchain *Blockchain) GetBlock(blockHash []byte) (Block, error)
func (*Blockchain) GetBlockHashes ¶
func (blockchain *Blockchain) GetBlockHashes() [][]byte
func (*Blockchain) Iterator ¶
func (blockchain *Blockchain) Iterator() *BlockchainIterator
func (*Blockchain) MineBlock ¶
func (blockchain *Blockchain) MineBlock(transactions []*Transaction) *Block
func (*Blockchain) SignTransaction ¶
func (blockchain *Blockchain) SignTransaction(transaction *Transaction, privateKey ecdsa.PrivateKey)
func (*Blockchain) VerifyTransaction ¶
func (blockchain *Blockchain) VerifyTransaction(transaction *Transaction) bool
type BlockchainIterator ¶
type BlockchainIterator struct {
// contains filtered or unexported fields
}
func (*BlockchainIterator) Next ¶
func (blockchainIterator *BlockchainIterator) Next() *Block
type Transaction ¶
type Transaction struct { ID []byte TransactionInputs []TransactionInput TransactionOutputs []TransactionOutput }
func DeserializeTransaction ¶
func DeserializeTransaction(data []byte) *Transaction
TODO: Use proto buffers
func NewCoinbaseTransaction ¶
func NewCoinbaseTransaction() *Transaction
func NewTransaction ¶
func NewTransaction(wallet *Wallet, to []byte, amount int, unspentTransactionOutputSet UnspentTransactionOutputSet) *Transaction
func (Transaction) IsCoinbase ¶
func (transaction Transaction) IsCoinbase() bool
func (*Transaction) Serialize ¶
func (transaction *Transaction) Serialize() []byte
TODO: Use proto buffers
func (*Transaction) Sign ¶
func (transaction *Transaction) Sign(privateKey ecdsa.PrivateKey, previousTransactions map[string]Transaction)
func (*Transaction) TrimmedCopy ¶
func (transaction *Transaction) TrimmedCopy() Transaction
func (*Transaction) Verify ¶
func (transaction *Transaction) Verify(previousTransactions map[string]Transaction) bool
type TransactionInput ¶
type TransactionInput struct { TransactionID []byte Signature []byte PublicKey []byte // contains filtered or unexported fields }
func (*TransactionInput) UsesKey ¶
func (transactionInput *TransactionInput) UsesKey(pubKeyHash []byte) bool
type TransactionOutput ¶
func NewTransactionOutput ¶
func NewTransactionOutput(value int, address []byte) *TransactionOutput
func (*TransactionOutput) IsLockedWithKey ¶
func (transactionOutput *TransactionOutput) IsLockedWithKey(pubKeyHash []byte) bool
func (*TransactionOutput) Lock ¶
func (transactionOutput *TransactionOutput) Lock(address []byte)
type TransactionOutputSet ¶
type TransactionOutputSet struct {
TransactionOutputs []TransactionOutput
}
func NewTransactionOutputSet ¶
func NewTransactionOutputSet(data []byte) TransactionOutputSet
func (TransactionOutputSet) Serialize ¶
func (transactionOutputSet TransactionOutputSet) Serialize() []byte
TODO: Maybe use proto buffs
type UnspentTransactionOutputSet ¶
type UnspentTransactionOutputSet struct {
Blockchain *Blockchain
}
func (UnspentTransactionOutputSet) CountTransactions ¶
func (unspentTransactionOutputSet UnspentTransactionOutputSet) CountTransactions() int
func (UnspentTransactionOutputSet) FindSpendableOutputs ¶
func (UnspentTransactionOutputSet) FindUnspentTransactionOutputs ¶
func (unspentTransactionOutputSet UnspentTransactionOutputSet) FindUnspentTransactionOutputs(publicKeyHash []byte) []TransactionOutput
func (UnspentTransactionOutputSet) Reindex ¶
func (unspentTransactionOutputSet UnspentTransactionOutputSet) Reindex()
TODO: Using this method should be avoided where possible
func (UnspentTransactionOutputSet) Update ¶
func (unspentTransactionOutputSet UnspentTransactionOutputSet) Update(block *Block)
type Wallet ¶
type Wallet struct { PrivateKey ecdsa.PrivateKey PublicKey []byte }
func (Wallet) GetAddress ¶
type Wallets ¶
func NewWallets ¶
func (*Wallets) CreateWallet ¶
func (*Wallets) GetAddresses ¶
func (Wallets) SaveToFile ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.