Documentation ¶
Overview ¶
This wallet code is specifically coupled with the node itself
Index ¶
- Constants
- func GeneratePrivKeyForNode(randseed int64) (crypto.PrivKey, error)
- func MineBlocks(bReceiver <-chan *Block, publisherTopic *pubsub.Topic)
- func PublicKeyHexToAddress(pubKeyHex string) (string, error)
- func StartNode(port int, randseed int64, connectAddr string) error
- func TransactionsToString(transactions []Transaction) string
- type Block
- type Blockchain
- type ColorLogger
- func (c *ColorLogger) Error(v ...interface{})
- func (c *ColorLogger) Errorf(format string, v ...interface{})
- func (c *ColorLogger) Info(v ...interface{})
- func (c *ColorLogger) Infof(format string, v ...interface{})
- func (c *ColorLogger) Success(v ...interface{})
- func (c *ColorLogger) Successf(format string, v ...interface{})
- func (c *ColorLogger) Warn(v ...interface{})
- func (c *ColorLogger) Warnf(format string, v ...interface{})
- type Input
- type Mempool
- type MyNotifiee
- type NodeIdentifier
- type Output
- type SyncRequest
- type SyncResponse
- type Transaction
- type UTXOSet
- type Wallet
Constants ¶
View Source
const ( Reset = "\033[0m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" )
Variables ¶
This section is empty.
Functions ¶
func MineBlocks ¶
func PublicKeyHexToAddress ¶
PublicKeyHexToAddress convert the base58-encoded public key pubkey to hexadecimal string of public key
func TransactionsToString ¶
func TransactionsToString(transactions []Transaction) string
Types ¶
type Block ¶
type Block struct { Height int `json:"height"` TxData []Transaction `json:"transaction_data"` Timestamps string `json:"timestamps"` Nonce int `json:"nonce"` Hash string `json:"hash"` PrevHash string `json:"prev_hash"` }
func NewBlock ¶
func NewBlock(tx Transaction) *Block
type Blockchain ¶
func NewBlockchain ¶
func NewBlockchain() *Blockchain
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(b *Block)
func (*Blockchain) GetLatestBlockHeight ¶
func (bc *Blockchain) GetLatestBlockHeight() int
type ColorLogger ¶
type ColorLogger struct {
// contains filtered or unexported fields
}
func NewColorLogger ¶
func NewColorLogger() *ColorLogger
func (*ColorLogger) Error ¶
func (c *ColorLogger) Error(v ...interface{})
func (*ColorLogger) Errorf ¶
func (c *ColorLogger) Errorf(format string, v ...interface{})
func (*ColorLogger) Info ¶
func (c *ColorLogger) Info(v ...interface{})
func (*ColorLogger) Infof ¶
func (c *ColorLogger) Infof(format string, v ...interface{})
func (*ColorLogger) Success ¶
func (c *ColorLogger) Success(v ...interface{})
func (*ColorLogger) Successf ¶
func (c *ColorLogger) Successf(format string, v ...interface{})
func (*ColorLogger) Warn ¶
func (c *ColorLogger) Warn(v ...interface{})
func (*ColorLogger) Warnf ¶
func (c *ColorLogger) Warnf(format string, v ...interface{})
type Input ¶
func GetInputsForTxByAddress ¶
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
func NewMempool ¶
func NewMempool() *Mempool
func (*Mempool) AddTransaction ¶
func (m *Mempool) AddTransaction(tx *Transaction)
func (*Mempool) RemoveTransaction ¶
type MyNotifiee ¶
type MyNotifiee struct{}
func (*MyNotifiee) Connected ¶
func (n *MyNotifiee) Connected(net network.Network, conn network.Conn)
func (*MyNotifiee) Disconnected ¶
func (n *MyNotifiee) Disconnected(net network.Network, conn network.Conn)
func (*MyNotifiee) ListenClose ¶
func (n *MyNotifiee) ListenClose(net network.Network, addr ma.Multiaddr)
type NodeIdentifier ¶
type Output ¶
func GetUTXOsByAddress ¶
type SyncRequest ¶
type SyncRequest struct {
FromHeight int `json:"from_height"`
}
type SyncResponse ¶
type SyncResponse struct {
Blocks []*Block `json:"blocks"`
}
type Transaction ¶
type Transaction struct { TxID string `json:"transaction_id"` Sender string `json:"sender"` Recipent string `json:"recipent"` Amount int `json:"amount"` Signature string `json:"signature"` Inputs []Input `json:"inputs"` Outputs []Output `json:"outputs"` IsCoinbase bool `json:"is_coinbase"` }
func GenerateCoinbaseTx ¶
func GenerateCoinbaseTx() Transaction
func GetUserTxHistory ¶
func GetUserTxHistory(walletAddress string) []Transaction
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privateKey *ecdsa.PrivateKey) error
Click to show internal directories.
Click to hide internal directories.