Documentation ¶
Index ¶
- Variables
- func Blockchain() *blockchain
- type Block
- type Coins
- type Hash
- type ID
- type Input
- type InputList
- type InputListRequestBody
- type InputRequestBody
- type Output
- type OutputList
- type OutputListRequestBody
- type OutputMap
- type OutputRequestBody
- type Signature
- type Transaction
- type TransactionIdIndexPair
- type TransactionList
- type TransactionMap
- type TransactionRequestBody
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ERROR_ABOVE_TARGET = errors.New("Block's hash is not below the target")
View Source
var ERROR_CONTAINS_INVALID_TRANSACTION = errors.New("Block contains invalid transactions")
View Source
var ERROR_EMPTY_SIGNATURE_STRING = errors.New("string is empty, cannot represent a signature")
View Source
var ERROR_INCORRECT_BODY_HASH = errors.New("Block's body hash has been incorrectly calculated")
View Source
var ERROR_INCORRECT_HASH_STRING_LENGTH = errors.New("string does not have the correct length to represent a hash")
View Source
var ERROR_INCORRECT_INDEX = errors.New("Block has incorrect index")
View Source
var ERROR_INSUFFICIENT_DATA = errors.New("Insufficient data")
View Source
var ERROR_INVALID_BLOCK = errors.New("Invalid Block")
View Source
var ERROR_INVALID_COINBASE_TRANSCTION = errors.New("Block's coinbase transaction collects more coins than expected")
View Source
var ERROR_INVALID_PEM_BLOCK = errors.New("PEM block is invalid")
View Source
var ERROR_LESS_TIMESTAMP = errors.New("Block's timestamp is less than parent's timestamp")
View Source
var ERROR_NOT_RSA_KEY = errors.New("the key is not an RSA key")
View Source
var ERROR_PARENT_HASH_MISMATCH = errors.New("Parent hash doesn't match with the hash of the block at that index")
View Source
var ERROR_TARGET_MISMATCH = errors.New("Block's target doesn't match with the current target")
View Source
var MyUser = User(config.MY_PUBLIC_KEY)
Functions ¶
func Blockchain ¶
func Blockchain() *blockchain
Types ¶
type Block ¶
type Block struct { Id ID `json:"_"` Index uint32 `json:"index"` ParentHash Hash `json:"parentHash"` BodyHash Hash `json:"bodyHash"` Target Hash `json:"target"` Timestamp int64 `json:"timestamp"` Nonce int64 `json:"nonce"` Transactions TransactionList `json:"transactions"` }
func BlockFromByteArray ¶
func NewGenesisBlock ¶
func NewGenesisBlock() Block
func (*Block) CalculateHeader ¶
func (Block) GetBodyHash ¶
func (Block) SaveToFile ¶
func (block Block) SaveToFile()
func (Block) ToByteArray ¶
type Hash ¶
type Hash [32]byte
func HashFromHexString ¶
func (Hash) IsLessThan ¶
func (Hash) MarshalJSON ¶
func (Hash) ToByteArray ¶
type Input ¶
type Input struct { TransactionId Hash `json:"transactionId"` OutputIndex uint32 `json:"index"` Signature Signature `json:"signature"` }
func (Input) ToByteArray ¶
type InputListRequestBody ¶
type InputListRequestBody []InputRequestBody
func (InputListRequestBody) ToInputList ¶
func (inputListRequestBody InputListRequestBody) ToInputList() (InputList, error)
type InputRequestBody ¶
type InputRequestBody struct { TransactionId string `json:"transactionId" binding:"required"` OutputIndex uint32 `json:"index" binding:"required"` Signature string `json:"signature" binding:"required"` }
func (InputRequestBody) ToInput ¶
func (inputRequestBody InputRequestBody) ToInput() (Input, error)
type Output ¶
func (Output) ToByteArray ¶
type OutputList ¶
type OutputList []Output
func OutputListFromByteArray ¶
func OutputListFromByteArray(data []byte) (OutputList, int, error)
func (OutputList) GetSumOfAmounts ¶
func (outputList OutputList) GetSumOfAmounts() Coins
func (OutputList) ToByteArray ¶
func (outputList OutputList) ToByteArray() []byte
type OutputListRequestBody ¶
type OutputListRequestBody []OutputRequestBody
func (OutputListRequestBody) ToOutputList ¶
func (outputListRequestBody OutputListRequestBody) ToOutputList() (OutputList, error)
type OutputMap ¶
type OutputMap = map[TransactionIdIndexPair]Output
type OutputRequestBody ¶
type OutputRequestBody struct { Recipient string `json:"recipient" binding:"required"` Amount json.Number `json:"amount" binding:"required"` }
func (OutputRequestBody) ToOutput ¶
func (outputRequestBody OutputRequestBody) ToOutput() (Output, error)
type Signature ¶
type Signature []byte
func SignatureFromHexString ¶
func (Signature) MarshalJSON ¶
func (Signature) ToByteArray ¶
type Transaction ¶
type Transaction struct { Id ID `json:"id"` Inputs InputList `json:"inputs"` Outputs OutputList `json:"outputs"` }
func TransactionFromByteArray ¶
func TransactionFromByteArray(data []byte) (Transaction, error)
func (*Transaction) AddInput ¶
func (txn *Transaction) AddInput(input Input)
func (*Transaction) AddOutput ¶
func (txn *Transaction) AddOutput(output Output)
func (*Transaction) CalculateHash ¶
func (txn *Transaction) CalculateHash() Hash
func (Transaction) CalculateOutputDataHash ¶
func (txn Transaction) CalculateOutputDataHash() Hash
func (Transaction) ToByteArray ¶
func (txn Transaction) ToByteArray() []byte
type TransactionIdIndexPair ¶
func (TransactionIdIndexPair) ToByteArray ¶
func (pair TransactionIdIndexPair) ToByteArray() []byte
type TransactionList ¶
type TransactionList []Transaction
func TransactionListFromByteArray ¶
func TransactionListFromByteArray(data []byte) (TransactionList, error)
func (TransactionList) ToByteArray ¶
func (txnList TransactionList) ToByteArray() []byte
type TransactionMap ¶
type TransactionMap map[Hash]Transaction
func (TransactionMap) MarshalJSON ¶
func (txnMap TransactionMap) MarshalJSON() ([]byte, error)
type TransactionRequestBody ¶
type TransactionRequestBody struct { Inputs InputListRequestBody `json:"inputs" binding:"required"` Outputs OutputListRequestBody `json:"outputs" binding:"required"` }
func (*TransactionRequestBody) ToTransaction ¶
func (txnRequestBody *TransactionRequestBody) ToTransaction() (Transaction, error)
Click to show internal directories.
Click to hide internal directories.