serialization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonceTooLong = errors.New("nonce is too long to insert into the transaction data field")

Functions

func ReadUint

func ReadUint(b []byte) (uint64, []byte, error)

func WriteUint

func WriteUint(b []byte, v uint64) []byte

Types

type Block

type Block struct {
	BlockHeader
	MinerTxn  Transaction
	TxnHashes [][32]byte
}

func (Block) GetBlob

func (b Block) GetBlob() []byte

func (Block) Serialize

func (b Block) Serialize() []byte

type BlockHeader

type BlockHeader struct {
	MajorVersion uint8
	MinorVersion uint8
	Timestamp    uint64
	PreviousID   [32]byte
	Nonce        uint32
}

func (BlockHeader) Serialize

func (bh BlockHeader) Serialize() []byte

type Transaction

type Transaction struct {
	TransactionPrefix
	Signatures [][32]byte
}

func (Transaction) Serialize

func (t Transaction) Serialize() []byte

type TransactionIn

type TransactionIn struct {
	Genesis    TransactionInGenesis
	Script     TransactionInToScript
	ScriptHash TransactionInToScriptHash
	Key        TransactionInToKey
}

func (TransactionIn) Serialize

func (ti TransactionIn) Serialize() []byte

type TransactionInGenesis

type TransactionInGenesis struct {
	Height uint64
	Used   bool
}

Transaction Inputs

func (TransactionInGenesis) Serialize

func (tig TransactionInGenesis) Serialize() []byte

type TransactionInToKey

type TransactionInToKey struct {
	Amount     uint64    // Amount of coin transferred
	KeyOffsets []uint64  // Key offsets are numeric ID's
	KeyImage   [32]uint8 // Key Image is a hex
	Used       bool
}

type TransactionInToScript

type TransactionInToScript struct {
	PreviousHash   [32]byte
	PreviousOutput uint64
	SignatureSet   []uint8
	Used           bool
}

type TransactionInToScriptHash

type TransactionInToScriptHash struct {
	PreviousHash   [32]byte
	PreviousOutput uint64
	Script         TransactionOutToScript
	SignatureSet   []uint8
	Used           bool
}

type TransactionOut

type TransactionOut struct {
	Amount     uint64
	Script     TransactionOutToScript
	ScriptHash TransactionOutToScriptHash
	Key        TransactionOutToKey
}

func (TransactionOut) Serialize

func (to TransactionOut) Serialize() []byte

type TransactionOutToKey

type TransactionOutToKey struct {
	Version   [1]byte
	PublicKey [32]byte
	Used      bool
	TaggedKey [1]byte
}

func (TransactionOutToKey) Serialize

func (totk TransactionOutToKey) Serialize() []byte

type TransactionOutToScript

type TransactionOutToScript struct {
	PublicKey [32]byte
	Script    []uint8
	Used      bool
}

Transaction Outputs

type TransactionOutToScriptHash

type TransactionOutToScriptHash struct {
	Hash [32]byte
	Used bool
}

type TransactionPrefix

type TransactionPrefix struct {
	Version         uint64
	UnlockTime      uint64
	TransactionsIn  []TransactionIn
	TransactionsOut []TransactionOut
	Extra           TxExtra
}

func (TransactionPrefix) Serialize

func (tp TransactionPrefix) Serialize() []byte

type TxExtra

type TxExtra struct {
	Padding        *[]byte // TX_EXTRA_TAG_PADDING - 0x00
	PubKey         []byte  // TX_EXTRA_TAG_PUBKEY - 0x01
	Nonce          []byte  // TX_EXTRA_NONCE - 0x02
	MergeMiningTag *[]byte // TX_EXTRA_MERGE_MINING_TAG - 0x03
	AddlPubKeys    *[]byte // TX_EXTRA_TAG_ADDITIONAL_PUBKEYS - 0x04
	MystMGTag      *[]byte // TX_EXTRA_MYSTERIOUS_MINERGATE_TAG - 0x0e
}

func ConstructTXExtra

func ConstructTXExtra(in []byte) TxExtra

func (*TxExtra) Serialize

func (txe *TxExtra) Serialize() []byte

func (*TxExtra) UpdateNonce

func (txe *TxExtra) UpdateNonce(in []byte) error

Jump to

Keyboard shortcuts

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