Documentation
¶
Index ¶
- func CollectFee(txs *[]Transaction) float64
- func GetChecksum(in []byte) []byte
- func HashPublicKey(publicKey []byte) []byte
- type Block
- type Blockchain
- func (bc *Blockchain) AddTransaction(tx *Transaction)
- func (bc *Blockchain) GetBalance(address string) float64
- func (bc *Blockchain) NewBlock(miner string)
- func (bc *Blockchain) NewTransaction(pk *rsa.PrivateKey, from string, to string, amount float64) Transaction
- func (bc *Blockchain) ReplaceBlockchain(blocks []Block)
- func (bc *Blockchain) ValidateChain() error
- type Transaction
- type Wallet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectFee ¶
func CollectFee(txs *[]Transaction) float64
func GetChecksum ¶
func HashPublicKey ¶
Types ¶
type Block ¶
type Block struct {
ID uint64 `json:"id"`
Transactions []Transaction `json:"transactions"`
Hash string `json:"hash"`
PrevHash string `json:"prev_hash"`
Timestamp int64 `json:"timestamp"`
Miner string `json:"miner"`
Reward float64 `json:"reward"`
Fee float64 `json:"fee"`
Nonce uint64 `json:"nonce"`
}
func (*Block) Mine ¶
func (b *Block) Mine(d int, txs *[]Transaction)
type Blockchain ¶
type Blockchain struct {
Blocks []Block `json:"blocks"`
Pending_txs []Transaction `json:"pending_txs"`
}
func InitBlockchain ¶
func InitBlockchain() *Blockchain
func LoadBlockchain ¶
func LoadBlockchain() *Blockchain
func (*Blockchain) AddTransaction ¶
func (bc *Blockchain) AddTransaction(tx *Transaction)
func (*Blockchain) GetBalance ¶
func (bc *Blockchain) GetBalance(address string) float64
func (*Blockchain) NewBlock ¶
func (bc *Blockchain) NewBlock(miner string)
func (*Blockchain) NewTransaction ¶
func (bc *Blockchain) NewTransaction(pk *rsa.PrivateKey, from string, to string, amount float64) Transaction
func (*Blockchain) ReplaceBlockchain ¶
func (bc *Blockchain) ReplaceBlockchain(blocks []Block)
func (*Blockchain) ValidateChain ¶
func (bc *Blockchain) ValidateChain() error
type Transaction ¶
type Transaction struct {
Hash string `json:"hash"`
From string `json:"from"`
To string `json:"to"`
Amount float64 `json:"amount"`
Fee float64 `json:"fee"`
Sign string `json:"sign"`
}
func NewTransaction ¶
func NewTransaction(privateKey *rsa.PrivateKey, from string, to string, amount float64) *Transaction
func (*Transaction) VerifyTransaction ¶
Click to show internal directories.
Click to hide internal directories.