structs

package
v0.0.0-...-507123f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: MIT Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const INPUTSIZE = int64(112)
View Source
const OUTPUTSIZE = int64(40)

Variables

View Source
var SIGNATURESIZE = 96

Functions

func BlockReward

func BlockReward(blockHeight int64) int64

func CheckDiff

func CheckDiff(hash []byte) int64

func DeletePendingTransaction

func DeletePendingTransaction(transactionHash []byte) error

func GenerateTransactionID

func GenerateTransactionID(t *Transaction) [32]byte

func GetBalance

func GetBalance(publicaddress string) int64

func GetBlockHashByHeight

func GetBlockHashByHeight(blockHeight int64) ([]byte, error)

func GetDifficulty

func GetDifficulty(blockHeight int64) int64

func ProcessBlock

func ProcessBlock(blk Block) error

func RequestBlockByHash

func RequestBlockByHash(messageHash []byte) ([]byte, error)

func RequestTransactionByHash

func RequestTransactionByHash(messageHash []byte, transactionBytes []byte) ([]byte, error)

func SaveNewBlock

func SaveNewBlock(blockHash []byte, blockBytes []byte, height int64) ([]byte, error)

func SavePendingTransaction

func SavePendingTransaction(transactionHash []byte, transactionBytes []byte) error

func SetBalance

func SetBalance(publicaddress string, newbal int64) error

func UpdateTransactionState

func UpdateTransactionState(transactionHash []byte, beginning string, ending string) error

Types

type Address

type Address struct {
	PrivateBytes    [32]byte // hex bytes
	PrivateReadable string
	PublicBytes     [32]byte // hex bytes
	PublicReadable  string
}

func (*Address) LoadBytesPrivate

func (a *Address) LoadBytesPrivate(PrivateBytes []byte) error

func (*Address) LoadBytesPublic

func (a *Address) LoadBytesPublic(ReadableBytes []byte) error

func (*Address) LoadRVMPublicAddress

func (a *Address) LoadRVMPublicAddress(ReadableAddress string) error

func (*Address) LoadRVSPrivateAddress

func (a *Address) LoadRVSPrivateAddress(ReadableAddress string) error

type Block

type Block struct {
	BlockHeight     int64
	Difficulty      int64
	LastBlockHash   []byte
	Transactions    []Transaction
	SignerPublicKey string
	Nonce           int64
	Signature       []byte
	Timestamp       int64
}

func GetBlockByHash

func GetBlockByHash(blockHash []byte) (Block, error)

func GetBlockByHeight

func GetBlockByHeight(blockHeight int64) (Block, error)

func (*Block) AddTransaction

func (b *Block) AddTransaction(transaction Transaction)

func (*Block) GetLength

func (b *Block) GetLength() (int64, error)

func (*Block) PrintBlock

func (b *Block) PrintBlock()

func (*Block) SetBlockNumber

func (b *Block) SetBlockNumber(blockHeight int64)

func (*Block) SetDifficulty

func (b *Block) SetDifficulty()

func (*Block) SignBlock

func (b *Block) SignBlock(privateKey []byte) error

func (*Block) SignatureBytes

func (b *Block) SignatureBytes() []byte

func (*Block) ToBytes

func (b *Block) ToBytes() ([]byte, error)

func (*Block) ToJSON

func (b *Block) ToJSON(bBytes []byte)

func (*Block) ValidateBlock

func (b *Block) ValidateBlock() error

type Transaction

type Transaction struct {
	TransactionID      []byte
	Inputs             []TransactionInput
	InputsHash         []byte
	Outputs            []TransactionOutput
	OutputsHash        []byte
	Messages           []TransactionMessage
	MessagesHash       []byte
	Timestamp          int64
	Signatures         []TransactionSignature
	RequiredSignatures int64
}

func GetPendingTransactionByHash

func GetPendingTransactionByHash(transactionHash []byte) (Transaction, error)

func GetTransactionByHash

func GetTransactionByHash(transactionHash []byte) ([]Transaction, error)

func GetTransactionsByAddress

func GetTransactionsByAddress(addressBytes []byte) ([]Transaction, error)

func (*Transaction) AddInput

func (t *Transaction) AddInput(Input TransactionInput) error

func (*Transaction) AddMessage

func (t *Transaction) AddMessage(Msg TransactionMessage) error

func (*Transaction) AddOutput

func (t *Transaction) AddOutput(Output TransactionOutput) error

func (*Transaction) AddSignature

func (t *Transaction) AddSignature(Signat TransactionSignature) error

func (*Transaction) AddSignedInput

func (t *Transaction) AddSignedInput(privateKey []byte, Input TransactionInput) error

sign it then call addinput signature is of

hash address
hash amoutn (as bigendian uint bytes)
hash timestamp
concatenate to 96 bytes

func (*Transaction) CalculateFee

func (t *Transaction) CalculateFee() int64

TODO.

func (*Transaction) GetLength

func (t *Transaction) GetLength() int64

func (*Transaction) HashInputs

func (t *Transaction) HashInputs() error

func (*Transaction) HashMessages

func (t *Transaction) HashMessages() error

func (*Transaction) HashOutputs

func (t *Transaction) HashOutputs() error

func (*Transaction) PrintTransaction

func (t *Transaction) PrintTransaction()

func (*Transaction) SetTransactionID

func (t *Transaction) SetTransactionID() error

func (*Transaction) SignTransaction

func (t *Transaction) SignTransaction(privateKey []byte) error

func (*Transaction) ToBytes

func (t *Transaction) ToBytes() []byte

func (*Transaction) ToJSON

func (t *Transaction) ToJSON(tBytes []byte) error

func (*Transaction) ValidateCoinbaseTransaction

func (t *Transaction) ValidateCoinbaseTransaction() error

func (*Transaction) ValidateTransaction

func (t *Transaction) ValidateTransaction() error

func (*Transaction) VerifyFee

func (t *Transaction) VerifyFee() int64

type TransactionInput

type TransactionInput struct {
	Address        [32]byte //32 bytes
	Amount         int64    // (this is a varint when in byte format)
	Timestamp      int64    // (this is a varint when in byte format)
	SignatureBytes [64]byte //64 bytes
}

func (*TransactionInput) AddAddressBytes

func (ti *TransactionInput) AddAddressBytes(AddressBytes []byte) error

func (*TransactionInput) AddAddressString

func (ti *TransactionInput) AddAddressString(AddressString string) error

func (*TransactionInput) AddAmount

func (ti *TransactionInput) AddAmount(Amount int64) error

func (*TransactionInput) AddSignature

func (ti *TransactionInput) AddSignature(Signature []byte) error

func (*TransactionInput) AddTimestamp

func (ti *TransactionInput) AddTimestamp(millitime int64) error

func (*TransactionInput) BytesToSign

func (ti *TransactionInput) BytesToSign() ([]byte, error)

func (*TransactionInput) GetLength

func (ti *TransactionInput) GetLength() int64

func (*TransactionInput) ToBytes

func (ti *TransactionInput) ToBytes() ([]byte, error)

func (*TransactionInput) ToJSON

func (ti *TransactionInput) ToJSON(InputBytes []byte) error

type TransactionMessage

type TransactionMessage struct {
	Key   []byte
	Value []byte
}

func (*TransactionMessage) GetLength

func (tm *TransactionMessage) GetLength() int64

func (*TransactionMessage) ToBytes

func (tm *TransactionMessage) ToBytes() ([]byte, error)

type TransactionOutput

type TransactionOutput struct {
	Address [32]byte //32 bytes
	Amount  int64    //8 bytes
}

func (*TransactionOutput) AddAddressBytes

func (to *TransactionOutput) AddAddressBytes(AddressBytes []byte) error

func (*TransactionOutput) AddAddressString

func (to *TransactionOutput) AddAddressString(AddressString string) error

func (*TransactionOutput) AddAmount

func (to *TransactionOutput) AddAmount(Amount int64) error

func (*TransactionOutput) GetLength

func (to *TransactionOutput) GetLength() int64

func (*TransactionOutput) ToBytes

func (to *TransactionOutput) ToBytes() ([]byte, error)

func (*TransactionOutput) ToJSON

func (to *TransactionOutput) ToJSON(OutputBytes []byte) error

type TransactionSignature

type TransactionSignature struct {
	SignatureAddress [32]byte
	SignatureBytes   [64]byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL