Documentation ¶
Index ¶
- Constants
- func Checksum(pubKeyHash []byte) []byte
- func DBExists(dbFile string) bool
- func HashPubKey(pub []byte) ([]byte, error)
- func IntToBytes(num int64) ([]byte, error)
- func ValidateAddress(address string) bool
- type Block
- type Blockchain
- func (bc *Blockchain) AddToPool(tx Transaction) error
- func (bc *Blockchain) FindTXByID(ID []byte) (Transaction, error)
- func (chain *Blockchain) FindUTXOsWithIDX() (map[string]map[int]TXOutput, error)
- func (chain *Blockchain) FindUXTOs() (map[string]TXOutputs, error)
- func (bc *Blockchain) GetBlockHeight() (uint64, error)
- func (bc *Blockchain) Iterator() *Iterator
- func (bc *Blockchain) MineBlock(txs []*Transaction) (Block, error)
- func (bc *Blockchain) SignTX(tx Transaction, privKey ecdsa.PrivateKey) error
- func (bc *Blockchain) VerifyTX(tx Transaction) (bool, error)
- type Iterator
- type MerkleNode
- type MerkleTree
- type PoW
- type TXInput
- type TXOutput
- type TXOutputs
- type Transaction
- func (tx Transaction) Hash() ([]byte, error)
- func (tx Transaction) IsCoinbase() bool
- func (tx Transaction) Serialize() ([]byte, error)
- func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transaction) error
- func (tx Transaction) TrimmedCopy() Transaction
- func (tx *Transaction) Verify(prevTXs map[string]Transaction) (bool, error)
- type UTXOSet
- type Wallet
Constants ¶
View Source
const ( AddressChecksumLen = 4 Version = byte(0x00) )
Variables ¶
This section is empty.
Functions ¶
func HashPubKey ¶
func IntToBytes ¶
func ValidateAddress ¶
Types ¶
type Block ¶
type Block struct { Timestamp int64 `json:"timestamp"` Nonce uint64 `json:"nonce"` PrevBlockHash []byte `json:"prev_block_hash"` Hash []byte `json:"hash"` Transactions []*Transaction `json:"transactions"` }
func DeserializeBlock ¶
func NewGenesisBlock ¶
func NewGenesisBlock(cbtx Transaction) (Block, error)
type Blockchain ¶
func CreateBlockchain ¶
func CreateBlockchain(address, dbFile string) (Blockchain, error)
func NewBlockchain ¶
func NewBlockchain(dbFile string) (Blockchain, error)
func (*Blockchain) AddToPool ¶
func (bc *Blockchain) AddToPool(tx Transaction) error
func (*Blockchain) FindTXByID ¶
func (bc *Blockchain) FindTXByID(ID []byte) (Transaction, error)
func (*Blockchain) FindUTXOsWithIDX ¶
func (chain *Blockchain) FindUTXOsWithIDX() (map[string]map[int]TXOutput, error)
scan the entire blockchain and find all UTXOs
func (*Blockchain) GetBlockHeight ¶
func (bc *Blockchain) GetBlockHeight() (uint64, error)
func (*Blockchain) Iterator ¶
func (bc *Blockchain) Iterator() *Iterator
func (*Blockchain) MineBlock ¶
func (bc *Blockchain) MineBlock(txs []*Transaction) (Block, error)
func (*Blockchain) SignTX ¶
func (bc *Blockchain) SignTX(tx Transaction, privKey ecdsa.PrivateKey) error
func (*Blockchain) VerifyTX ¶
func (bc *Blockchain) VerifyTX(tx Transaction) (bool, error)
type MerkleNode ¶
type MerkleNode struct { Left *MerkleNode Right *MerkleNode Data []byte }
type MerkleTree ¶
type MerkleTree struct {
Root *MerkleNode
}
func NewMerkleTree ¶
func NewMerkleTree(data [][]byte) *MerkleTree
type TXInput ¶
type TXOutput ¶
func (TXOutput) IsLockedWith ¶
check if the output can be unlocked
type Transaction ¶
type Transaction struct { ID []byte `json:"id"` Inputs []TXInput `json:"inputs"` Outputs []TXOutput `json:"outputs"` Msg string `json:"msg"` }
func DeserializeTX ¶
func DeserializeTX(data []byte) (Transaction, error)
func NewCBTX ¶
func NewCBTX(address, data string) (Transaction, error)
func NewUTXOTransaction ¶
func (Transaction) Hash ¶
func (tx Transaction) Hash() ([]byte, error)
func (Transaction) IsCoinbase ¶
func (tx Transaction) IsCoinbase() bool
func (Transaction) Serialize ¶
func (tx Transaction) Serialize() ([]byte, error)
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transaction) error
func (Transaction) TrimmedCopy ¶
func (tx Transaction) TrimmedCopy() Transaction
func (*Transaction) Verify ¶
func (tx *Transaction) Verify(prevTXs map[string]Transaction) (bool, error)
type UTXOSet ¶
type UTXOSet struct {
Blockchain *Blockchain
}
func (*UTXOSet) FindSpendableOutputs ¶
type Wallet ¶
type Wallet struct { PrivKey ecdsa.PrivateKey PubKey []byte }
func (*Wallet) DecodePrivKeys ¶
func (*Wallet) DecodePubKeys ¶
func (Wallet) EncodePrivKeys ¶
func (Wallet) EncodePubKeys ¶
func (Wallet) GetAddress ¶
Click to show internal directories.
Click to hide internal directories.