core

package
v5.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifySize

func VerifySize(chainType consensus.ChainType, prePoW []uint8, bh *BlockHeader) error

VerifySize validates the proof of work of a given header, and that the proof of work satisfies the requirements of the header.

Types

type BlockHeader

type BlockHeader struct {
	// Version of the block
	Version uint16
	// Height of this block since the genesis block (height 0)
	Height uint64
	// Hash of the block previous to this in the chain.
	PrevHash string
	// Root hash of the header MMR at the previous header.
	PrevRoot string
	// Timestamp at which the block was built.
	Timestamp string
	// Merklish root of all the commitments in the TxHashSet
	OutputRoot string
	// Merklish root of all range proofs in the TxHashSet
	RangeProofRoot string
	// Merklish root of all transaction kernels in the TxHashSet
	KernelRoot string
	// Total accumulated sum of kernel offsets since genesis block.
	// We can derive the kernel offset sum for *this* block from
	// the total kernel offset of the previous block header.
	TotalKernelOffset string
	// Total size of the output MMR after applying this block
	OutputMmrSize uint64
	// Total size of the kernel MMR after applying this block
	KernelMmrSize uint64
	// Proof of work and related
	PoW pow.ProofOfWork
}

BlockHeader is a block header, fairly standard compared to other blockchains.

type Input

type Input struct {
	// The features of the output being spent.
	// We will check maturity for coinbase output.
	Features OutputFeatures `json:"features"`
	// The commit referencing the output being spent.
	Commit string `json:"commit"`
}

Input is a transaction input.

Primarily a reference to an output being spent by the transaction.

type KernelFeatures

type KernelFeatures int

KernelFeatures is an enum of various supported kernels "features".

const (
	// PlainKernel kernel (the default for Grin txs).
	PlainKernel KernelFeatures = iota
	// CoinbaseKernel is a coinbase kernel.
	CoinbaseKernel
	// HeightLockedKernel is a kernel with an explicit lock height.
	HeightLockedKernel
	// NoRecentDuplicateKernel is a NRD kernel
	NoRecentDuplicateKernel
)

func (KernelFeatures) MarshalJSON

func (s KernelFeatures) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (KernelFeatures) String

func (s KernelFeatures) String() string

func (*KernelFeatures) UnmarshalJSON

func (s *KernelFeatures) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted json string to the enum value

type Output

type Output struct {
	// Options for an output's structure or use
	Features OutputFeatures `json:"features"`
	// The homomorphic commitment representing the output amount
	Commit string `json:"commit"`
	// A proof that the commitment is in the right range
	Proof string `json:"proof"`
}

Output for a transaction, defining the new ownership of coins that are being transferred. The commitment is a blinded value for the output while the range proof guarantees the commitment includes a positive value without overflow and the ownership of the private key. The switch commitment hash provides future-proofing against quantum-based attacks, as well as providing wallet implementations with a way to identify their outputs for wallet reconstruction.

type OutputFeatures

type OutputFeatures int

OutputFeatures is an enum of various supported outputs "features".

const (
	// PlainOutput output (the default for Grin txs).
	PlainOutput OutputFeatures = iota
	// CoinbaseOutput is a coinbase output.
	CoinbaseOutput
)

func (OutputFeatures) MarshalJSON

func (s OutputFeatures) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (OutputFeatures) String

func (s OutputFeatures) String() string

func (*OutputFeatures) UnmarshalJSON

func (s *OutputFeatures) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a quoted json string to the enum value

type OutputIdentifier

type OutputIdentifier struct {
	// Output features (coinbase vs. regular transaction output)
	// We need to include this when hashing to ensure coinbase maturity can be
	// enforced.
	Features OutputFeatures `json:"features"`
	// Output commitment
	Commit string `json:"commit"`
}

An OutputIdentifier can be build from either an input _or_ an output and contains everything we need to uniquely identify an output being spent. Needed because it is not sufficient to pass a commitment around.

type Transaction

type Transaction struct {
	// The kernel "offset" k2
	// excess is k1G after splitting the key k = k1 + k2
	Offset string `json:"offset"`
	// The transaction body - inputs/outputs/kernels
	Body TransactionBody `json:"body"`
}

Transaction represents a transaction

type TransactionBody

type TransactionBody struct {
	// List of inputs spent by the transaction.
	Inputs []Input `json:"inputs"`
	// List of outputs the transaction produces.
	Outputs []Output `json:"outputs"`
	// List of kernels that make up this transaction (usually a single kernel).
	Kernels []TxKernel `json:"kernels"`
}

TransactionBody is a common abstraction for transaction and block

type TxKernel

type TxKernel struct {
	// Options for a kernel's structure or use
	Features KernelFeatures `json:"features"`
	// Remainder of the sum of all transaction commitments. If the transaction
	// is well formed, amounts components should sum to zero and the excess
	// is hence a valid public key.
	Excess string `json:"excess"`
	// The signature proving the excess is a valid public key, which signs
	// the transaction fee.
	ExcessSig string `json:"excess_sig"`
}

TxKernel is a proof that a transaction sums to zero. Includes both the transaction's Pedersen commitment and the signature, that guarantees that the commitments amount to zero. The signature signs the fee and the lock_height, which are retained for signature validation.

type Uint64

type Uint64 uint64

Uint64 is an uint64 that can be unmarshal from a string or uint64 is marshal to a string

func (Uint64) MarshalJSON

func (u Uint64) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Uint64 as a quoted uint64 string

func (*Uint64) UnmarshalJSON

func (u *Uint64) UnmarshalJSON(bs []byte) error

UnmarshalJSON unmarshals a quoted an uint64 or a string to an uint64 value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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