Documentation ¶
Index ¶
- Constants
- Variables
- func AddInUse(utxoBucket []byte) (inUseID int)
- func Base58Decode(input []byte) []byte
- func Base58Encode(input []byte) []byte
- func ByteToUint32(b []byte) (num uint32)
- func CheckErr(err error)
- func CliCheckErr(err error)
- func ConnectDefaultHub(db *bolt.DB)
- func ConnectHubs(db *bolt.DB)
- func ContractChainBlockHashDecodeString(contractChainBlockHashString string) (contractChainBlockHash [20]byte, err error)
- func ExcludeNode(addr string, db *bolt.DB)
- func GetAddress(pubKeyHash [20]byte) []byte
- func GetBalance(address, nodeID string, printDetail bool) (balance, balanceSpendable uint32)
- func GetPrivateKey(pubKeyHash [20]byte, wallets *Wallets) (ecdsa.PrivateKey, error)
- func GetUTXOBucketID(utxoBucket []byte) (utxoBucketID string)
- func HasBeenRegisteredOnBlockchain(nodeID string, wallet *Wallet) (register bool, err error)
- func HashPubKey(pubKey []byte) [20]byte
- func Int64ToByte(num int64) []byte
- func IsInUse(utxoBucket []byte) (isInUse bool)
- func NewMerkleNode(left, right [32]byte) [32]byte
- func NewMerkleTree(data [][32]byte) [32]byte
- func NodeIsOnBlacklist(addr string) (nodeIsOnBlacklist bool)
- func PrintErr(err interface{})
- func PrintMessage(str string)
- func PutOnBlacklist(addr string)
- func RemoteAddr(version uint32, isStaticAddr bool, staticHost, port, remoteAddrHost string) (string, error)
- func Reverse20ByteHashes(data [][20]byte)
- func ReverseBytes(data []byte)
- func ReverseHashes(data [][32]byte)
- func SendAdminEmail(message string)
- func SendConfirmedBlockInfo(addr string, bc *Blockchain)
- func SendMiningJob(addr string, prepareData []byte, difficulty uint8)
- func SendTXIDs(db *bolt.DB)
- func StartMine(bc *Blockchain, batch uint32, maxNonce uint64, sleep uint8)
- func StartServer(nodeID, minerAddress, from, to string, sendNewTx bool, amount uint32)
- func Subsidy(blockHeight uint32) uint32
- func Uint32ToByte(num uint32) []byte
- func Uint64ToByte(num uint64) []byte
- func Uint8ToByte(num uint8) []byte
- func ValidateAddrHost(addr string) error
- func ValidateAddress(address string) bool
- func ValidateBlockChain(blockchain string) error
- func VerifyBlockHeaderWithoutChain(block *Block) (err error)
- func VerifyBlockWithoutChain(block *Block) error
- func VerifyCoinbaseWithoutChain(coinbase *Transaction, txAmount int) error
- func VerifyTransactionWithoutChain(tx *Transaction) (uint32, error)
- func VerifyTransactionsWithoutChain(txs []*Transaction) error
- type Block
- type BlockHeader
- type Blockchain
- func (bc *Blockchain) AddLastBlock(block *Block) error
- func (bc *Blockchain) ChangeMainChain(bestHeight uint32, lastHash [32]byte)
- func (bc *Blockchain) FindTXOutputPubKeyHash(blockHash, txid [32]byte, index int8) ([20]byte, error)
- func (bc *Blockchain) GetBlock(blockHash [32]byte) (*Block, error)
- func (bc *Blockchain) GetBlockHashes() *[][32]byte
- func (bc *Blockchain) GetValidDifficulty(block *Block) uint8
- func (bc *Blockchain) Iterator() *BlockchainIterator
- func (bc *Blockchain) MineBlock(transactions []*Transaction, batch uint32, maxNonce uint64, sleep uint8) (*Block, error)
- func (bc *Blockchain) RebuildBlockHashesFromGenesisToTip()
- func (bc *Blockchain) SetDifficulty(height uint32, prevBlock [32]byte) uint8
- func (bc *Blockchain) Trim()
- func (bc *Blockchain) UpdateMainChain(blockHash [32]byte, block *Block)
- func (bc *Blockchain) VerifyBlock(block *Block, blockHashes *[][32]byte) error
- func (bc *Blockchain) VerifyBlockHashCollision(blockHash [32]byte) error
- func (bc *Blockchain) VerifyBlockHeader(block *Block) error
- func (bc *Blockchain) VerifyCoinbase(block *Block) error
- func (bc *Blockchain) VerifyLog(blockHash [32]byte, isValid bool)
- func (bc *Blockchain) VerifyProtect() error
- func (bc *Blockchain) VerifyTransaction(index int, block *Block, blockHashes *[][32]byte) error
- func (bc *Blockchain) VerifyTransactions(block *Block, blockHashes *[][32]byte) error
- type BlockchainIterator
- type BlockchainIteratorTwo
- type CLI
- type ContractBlock
- type ContractChain
- type ContractChainIterator
- type ProofOfWork
- type SpendableOutput
- type SpendableOutputs
- type SpendedOutput
- type SpendedOutputs
- type TXInput
- type TXOutput
- type Transaction
- func (tnx *Transaction) AddNewTxToBucket(db *bolt.DB) error
- func (tx *Transaction) Hash() [32]byte
- func (tx *Transaction) IsCoinbase() bool
- func (tx *Transaction) MarshalJSON() []byte
- func (tx *Transaction) Serialize() []byte
- func (tx *Transaction) Sign(wallets *Wallets, bc *Blockchain)
- func (tx *Transaction) String() string
- func (tx *Transaction) TrimmedCopy() *Transaction
- func (tx *Transaction) VerifySign(bc *Blockchain) bool
- func (tx *Transaction) VerifySize() (uint32, error)
- type UTXOSet
- func (u UTXOSet) Balance(pubKeyHash [20]byte, printDetail bool) (balance, balanceSpendable uint32)
- func (u UTXOSet) FindSpendableOutputs(usableWallets *Wallets, amountAndFee uint32) (uint32, *ValidOutputs, error)
- func (u UTXOSet) GetAvailableUTXO() (utxoBucket, contractBucket []byte)
- func (u UTXOSet) GetUTXOLastBlock(utxoBucket []byte) (utxoLastBlockHash [32]byte)
- func (u UTXOSet) GetUnAvailableUTXO() (utxoBucket, contractBucket []byte)
- func (u UTXOSet) Rebuild(utxoBucket, contractBucket []byte) error
- func (u UTXOSet) Reindex() error
- func (u UTXOSet) ResetUTXOLastBlock(utxoBucket []byte)
- func (u UTXOSet) SetAvailable(utxoBucket []byte, utxoLastBlockHash [32]byte)
- func (u UTXOSet) Update(utxoBucket, contractBucket []byte, block *Block)
- func (u UTXOSet) UpdateLastBlock() error
- type UTXOutput
- type UTXOutputs
- type ValidOutput
- type ValidOutputs
- type Wallet
- type Wallets
Constants ¶
View Source
const ( IsTest = false DefaultHubIsIP = false DefaultHub = "each1.net:1024" SetLocalhostStaticIPAddr = false LocalhostStaticIPAddr = "" SetLocalhostDomainName = false LocalhostDomainName = "" )
View Source
const (
CommandLength uint8 = 14
)
Variables ¶
View Source
var ( MiningAddress string WebServerLanAddress string )
Functions ¶
func Base58Decode ¶
func Base58Encode ¶
func ByteToUint32 ¶
func CliCheckErr ¶
func CliCheckErr(err error)
func ConnectDefaultHub ¶
func ConnectHubs ¶
func ExcludeNode ¶
func GetAddress ¶
func GetBalance ¶
func GetPrivateKey ¶
func GetPrivateKey(pubKeyHash [20]byte, wallets *Wallets) (ecdsa.PrivateKey, error)
func GetUTXOBucketID ¶
func HashPubKey ¶
func Int64ToByte ¶
func NewMerkleNode ¶
func NewMerkleTree ¶
func NodeIsOnBlacklist ¶
func PrintMessage ¶
func PrintMessage(str string)
func PutOnBlacklist ¶
func PutOnBlacklist(addr string)
func RemoteAddr ¶
func Reverse20ByteHashes ¶
func Reverse20ByteHashes(data [][20]byte)
func ReverseBytes ¶
func ReverseBytes(data []byte)
func ReverseHashes ¶
func ReverseHashes(data [][32]byte)
func SendAdminEmail ¶
func SendAdminEmail(message string)
func SendConfirmedBlockInfo ¶
func SendConfirmedBlockInfo(addr string, bc *Blockchain)
func SendMiningJob ¶
func StartServer ¶
func Uint32ToByte ¶
func Uint64ToByte ¶
func Uint8ToByte ¶
func ValidateAddrHost ¶
func ValidateAddress ¶
func ValidateBlockChain ¶
func VerifyBlockWithoutChain ¶
func VerifyCoinbaseWithoutChain ¶
func VerifyCoinbaseWithoutChain(coinbase *Transaction, txAmount int) error
func VerifyTransactionWithoutChain ¶
func VerifyTransactionWithoutChain(tx *Transaction) (uint32, error)
func VerifyTransactionsWithoutChain ¶
func VerifyTransactionsWithoutChain(txs []*Transaction) error
Types ¶
type Block ¶
type Block struct { Header *BlockHeader Transactions []*Transaction }
func DeserializeBlock ¶
func NewBlock ¶
func NewBlock(prevBlock [32]byte, transactions []*Transaction, difficulty uint8, bc *Blockchain, batch uint32, maxNonce uint64, sleep uint8) (*Block, error)
func NewGenesisBlock ¶
func NewGenesisBlock(coinbase *Transaction, bc *Blockchain) *Block
func (*Block) HashTransactions ¶
type BlockHeader ¶
type BlockHeader struct { Version uint32 PrevBlock [32]byte MerkleRoot [32]byte Timestamp int64 Difficulty uint8 Nonce uint64 }
func NewBlockHeader ¶
func NewBlockHeader(prevBlock, merkleRoot [32]byte, difficulty uint8, bc *Blockchain, batch uint32, maxNonce uint64, sleep uint8) (*BlockHeader, error)
func (*BlockHeader) HashBlockHeader ¶
func (bh *BlockHeader) HashBlockHeader() [32]byte
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
func NewBlockchain ¶
func NewBlockchain(nodeID string) *Blockchain
func (*Blockchain) AddLastBlock ¶
func (bc *Blockchain) AddLastBlock(block *Block) error
func (*Blockchain) ChangeMainChain ¶
func (bc *Blockchain) ChangeMainChain(bestHeight uint32, lastHash [32]byte)
func (*Blockchain) FindTXOutputPubKeyHash ¶
func (bc *Blockchain) FindTXOutputPubKeyHash(blockHash, txid [32]byte, index int8) ([20]byte, error)
func (*Blockchain) GetBlockHashes ¶
func (bc *Blockchain) GetBlockHashes() *[][32]byte
func (*Blockchain) GetValidDifficulty ¶
func (bc *Blockchain) GetValidDifficulty(block *Block) uint8
func (*Blockchain) Iterator ¶
func (bc *Blockchain) Iterator() *BlockchainIterator
func (*Blockchain) MineBlock ¶
func (bc *Blockchain) MineBlock(transactions []*Transaction, batch uint32, maxNonce uint64, sleep uint8) (*Block, error)
func (*Blockchain) RebuildBlockHashesFromGenesisToTip ¶
func (bc *Blockchain) RebuildBlockHashesFromGenesisToTip()
func (*Blockchain) SetDifficulty ¶
func (bc *Blockchain) SetDifficulty(height uint32, prevBlock [32]byte) uint8
func (*Blockchain) Trim ¶
func (bc *Blockchain) Trim()
func (*Blockchain) UpdateMainChain ¶
func (bc *Blockchain) UpdateMainChain(blockHash [32]byte, block *Block)
func (*Blockchain) VerifyBlock ¶
func (bc *Blockchain) VerifyBlock(block *Block, blockHashes *[][32]byte) error
func (*Blockchain) VerifyBlockHashCollision ¶
func (bc *Blockchain) VerifyBlockHashCollision(blockHash [32]byte) error
func (*Blockchain) VerifyBlockHeader ¶
func (bc *Blockchain) VerifyBlockHeader(block *Block) error
func (*Blockchain) VerifyCoinbase ¶
func (bc *Blockchain) VerifyCoinbase(block *Block) error
func (*Blockchain) VerifyLog ¶
func (bc *Blockchain) VerifyLog(blockHash [32]byte, isValid bool)
func (*Blockchain) VerifyProtect ¶
func (bc *Blockchain) VerifyProtect() error
func (*Blockchain) VerifyTransaction ¶
func (bc *Blockchain) VerifyTransaction(index int, block *Block, blockHashes *[][32]byte) error
func (*Blockchain) VerifyTransactions ¶
func (bc *Blockchain) VerifyTransactions(block *Block, blockHashes *[][32]byte) error
type BlockchainIterator ¶
type BlockchainIterator struct {
// contains filtered or unexported fields
}
func (*BlockchainIterator) Next ¶
func (i *BlockchainIterator) Next() (block *Block)
type BlockchainIteratorTwo ¶
type BlockchainIteratorTwo struct {
// contains filtered or unexported fields
}
func (*BlockchainIteratorTwo) NextIfBlockExists ¶
func (i *BlockchainIteratorTwo) NextIfBlockExists() (findNonExistingBlock, findIllegalBlock bool, blockHash [32]byte, height uint32)
type ContractBlock ¶
type ContractBlock struct { Version uint32 PrevBlock [20]byte Height uint32 Timestamp int64 FileName []byte File []byte }
func DeserializeContractBlock ¶
func DeserializeContractBlock(d []byte) *ContractBlock
func (*ContractBlock) HashBlock ¶
func (b *ContractBlock) HashBlock() [20]byte
func (*ContractBlock) Serialize ¶
func (b *ContractBlock) Serialize() []byte
type ContractChain ¶
type ContractChain struct {
// contains filtered or unexported fields
}
func NewContractChain ¶
func NewContractChain(address string) *ContractChain
func (*ContractChain) Iterator ¶
func (cc *ContractChain) Iterator() *ContractChainIterator
type ContractChainIterator ¶
type ContractChainIterator struct {
// contains filtered or unexported fields
}
func (*ContractChainIterator) Next ¶
func (i *ContractChainIterator) Next() (block *ContractBlock)
type ProofOfWork ¶
type ProofOfWork struct {
// contains filtered or unexported fields
}
func NewProofOfWork ¶
func NewProofOfWork(bh *BlockHeader) *ProofOfWork
func (*ProofOfWork) Run ¶
func (pow *ProofOfWork) Run(bc *Blockchain, batch uint32, maxNonce uint64, sleep uint8) (uint64, error)
func (*ProofOfWork) Validate ¶
func (pow *ProofOfWork) Validate() bool
type SpendableOutput ¶
type SpendableOutputs ¶
type SpendableOutputs struct {
Outputs []*SpendableOutput
}
type SpendedOutput ¶
type SpendedOutputs ¶
type SpendedOutputs struct {
Outputs []*SpendedOutput
}
type TXOutput ¶
func NewTXOutput ¶
type Transaction ¶
func DeserializeTransaction ¶
func DeserializeTransaction(data []byte) Transaction
func NewCoinbaseTX ¶
func NewCoinbaseTX(to string, txAmount uint, blockHeight uint32) *Transaction
func NewUTXOTransaction ¶
func NewUTXOTransaction(from, to string, amount uint32, bc *Blockchain) (tx *Transaction, err error)
func (*Transaction) AddNewTxToBucket ¶
func (tnx *Transaction) AddNewTxToBucket(db *bolt.DB) error
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() [32]byte
func (*Transaction) IsCoinbase ¶
func (tx *Transaction) IsCoinbase() bool
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() []byte
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize() []byte
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(wallets *Wallets, bc *Blockchain)
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) TrimmedCopy ¶
func (tx *Transaction) TrimmedCopy() *Transaction
func (*Transaction) VerifySign ¶
func (tx *Transaction) VerifySign(bc *Blockchain) bool
func (*Transaction) VerifySize ¶
func (tx *Transaction) VerifySize() (uint32, error)
type UTXOSet ¶
type UTXOSet struct {
Blockchain *Blockchain
}
func (UTXOSet) FindSpendableOutputs ¶
func (UTXOSet) GetAvailableUTXO ¶
func (UTXOSet) GetUTXOLastBlock ¶
func (UTXOSet) GetUnAvailableUTXO ¶
func (UTXOSet) ResetUTXOLastBlock ¶
func (UTXOSet) SetAvailable ¶
func (UTXOSet) UpdateLastBlock ¶
type UTXOutputs ¶
type UTXOutputs struct {
Outputs []*UTXOutput
}
func DeserializeUTXOutputs ¶
func DeserializeUTXOutputs(data []byte) UTXOutputs
func (*UTXOutputs) Serialize ¶
func (outs *UTXOutputs) Serialize() []byte
type ValidOutput ¶
type ValidOutputs ¶
type ValidOutputs struct {
Outputs []*ValidOutput
}
type Wallet ¶
type Wallet struct { PrivateKey ecdsa.PrivateKey PublicKey []byte }
type Wallets ¶
func NewWallets ¶
func (*Wallets) CreateWallet ¶
func (*Wallets) GetAddresses ¶
func (*Wallets) LoadFromFile ¶
func (Wallets) SaveToFile ¶
Source Files ¶
- base58.go
- block.go
- blockchain.go
- blockchain_iterator.go
- blockheader.go
- cli.go
- cli_createwallet.go
- cli_datacleansing.go
- cli_getbalance.go
- cli_listaddress.go
- cli_printchain.go
- cli_printransaction.go
- cli_printxsbucket.go
- cli_reindexutxo.go
- cli_send.go
- cli_sendtxs.go
- cli_startnode.go
- cli_statistic.go
- cli_tool.go
- cli_validate.go
- config.go
- contract.go
- hub.go
- merkle_tree.go
- proofofwork.go
- server.go
- server_mining_pool.go
- settings.go
- transaction.go
- transaction_input.go
- transaction_output.go
- utils.go
- utxo_set.go
- wallet.go
- wallets.go
Click to show internal directories.
Click to hide internal directories.