Documentation
¶
Index ¶
- Constants
- func AddressToPubKeyHash(address []byte) []byte
- func HashPubKey(pubKey []byte) []byte
- func ValidateAddress(address []byte) bool
- type Block
- type Blockchain
- type BlockchainIterator
- type CLI
- type MerkleNode
- type MerkleTree
- type ProofOfWork
- type TXInput
- type TXOutput
- type Transaction
- type TransactionPool
- type UTXO
- type UTXOPool
- type Wallet
- type Wallets
Constants ¶
const Version = byte(0x00)
Version Glockchain version
const WalletVersion = byte(0x00)
WalletVersion Wallet Version
Variables ¶
This section is empty.
Functions ¶
func AddressToPubKeyHash ¶
AddressToPubKeyHash is convert address to pubkeyhash
func ValidateAddress ¶
ValidateAddress is validation address
Types ¶
type Block ¶
type Block struct {
Index int64
PreviousHash []byte
Timestamp int64
Hash []byte
Nonce int
Transactions []*Transaction
TXHash []byte
}
Block is transaction block
func DeserializeBlock ¶
DeserializeBlock is deserializing block
func NewBlock ¶
func NewBlock(transactions []*Transaction, prevBlockHash []byte) *Block
NewBlock is block constructor transactions is the transaction you want to add to the block
func NewGenesisBlock ¶
func NewGenesisBlock(tx *Transaction) *Block
NewGenesisBlock is created genesis block tx is the coinbase transaction
func (*Block) HashTransactions ¶
HashTransactions is hasing transacitons from block
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain is chain with block tip is last block hash
func CreateBlockchain ¶
func CreateBlockchain(address []byte) *Blockchain
CreateBlockchain is create blockchain if blockchain exists, error it
func GetBlockchain ¶
func GetBlockchain() (*Blockchain, []byte)
GetBlockchain is Getting exist blockchain
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block *Block)
AddBlock is adding block into blockchain
func (*Blockchain) Iterator ¶
func (bc *Blockchain) Iterator() *BlockchainIterator
Iterator is created blockchain iterator
type BlockchainIterator ¶
type BlockchainIterator struct {
// contains filtered or unexported fields
}
BlockchainIterator is a blockchain iterator
func (*BlockchainIterator) Next ¶
func (bci *BlockchainIterator) Next() *Block
Next is moved index for next
type MerkleNode ¶
type MerkleNode struct {
Left *MerkleNode
Right *MerkleNode
Data []byte
}
MerkleNode MerkleTree Node
func NewMerkleNode ¶
func NewMerkleNode(left, right *MerkleNode, data []byte) *MerkleNode
NewMerkleNode MerkleNode constructor
type MerkleTree ¶
type MerkleTree struct {
RootNode *MerkleNode
}
MerkleTree Transaction hash tree
func NewMerkleTree ¶
func NewMerkleTree(data [][]byte) *MerkleTree
NewMerkleTree MerkleTree constructor
type ProofOfWork ¶
type ProofOfWork struct {
// contains filtered or unexported fields
}
ProofOfWork mining action with ProofOfWork
func NewProofOfWork ¶
func NewProofOfWork(b *Block) *ProofOfWork
NewProofOfWork ProofOfWork constructor
type TXInput ¶
TXInput Transaction Input
func NewTXInput ¶
func NewTXInput(prevTX Transaction, prevTXIndex int) *TXInput
NewTXInput TXInput constructor
type TXOutput ¶
TXOutput Transaction output
func NewTXOutput ¶
NewTXOutput TXOutput constructor
func (*TXOutput) IsLockedWithKey ¶
IsLockedWithKey Is Locked with args keyhash?
type Transaction ¶
type Transaction struct {
Version byte
ID []byte
BlockHash []byte
Input []TXInput
Output []TXOutput
}
Transaction TX Data
func DeserializeTransaction ¶
func DeserializeTransaction(data []byte) Transaction
DeserializeTransaction deserialize tx
func NewCoinbaseTX ¶
func NewCoinbaseTX(value int, to []byte) *Transaction
NewCoinbaseTX Create New Coinbase TX
func NewTransaction ¶
func NewTransaction(wallet *Wallet, to []byte, amount int) *Transaction
NewTransaction create New TX
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) TrimmedCopy ¶
func (tx *Transaction) TrimmedCopy() Transaction
TrimmedCopy copy TX (not in TXI pubkey and Signature)
type TransactionPool ¶
type TransactionPool struct {
Pool []*Transaction
}
TransactionPool Not take up transaction into block
func NewTransactionPool ¶
func NewTransactionPool() *TransactionPool
NewTransactionPool TransactionPool constructor
func (*TransactionPool) AddTransaction ¶
func (txp *TransactionPool) AddTransaction(transaction *Transaction)
AddTransaction Pool Transaciton
func (*TransactionPool) ClearTransactionPool ¶
func (txp *TransactionPool) ClearTransactionPool()
ClearTransactionPool clear pool
type UTXOPool ¶
UTXOPool is singleton
func (*UTXOPool) AddUTXO ¶
func (up *UTXOPool) AddUTXO(t *Transaction)
AddUTXO is create UTXO and Pooling UTXP
func (*UTXOPool) FindSpendableOutputs ¶
FindSpendableOutputs is finc tx from pool with pubkeyhash ando amount
type Wallet ¶
type Wallet struct {
PrivateKey ecdsa.PrivateKey
PublicKey []byte
}
Wallet is Glockchain Wallet private and publick keyValue pair
func (Wallet) GetAddress ¶
GetAddress is create address from pub/private key
type Wallets ¶
Wallets is Wallet collection
func (*Wallets) CreateWallet ¶
CreateWallet is created wallet and added Wallets collection
func (*Wallets) GetAddresses ¶
GetAddresses is calling wallet function with Wallets collection
func (*Wallets) LoadFromFile ¶
LoadFromFile is Loading wallets from file