ledger

package
v0.0.0-...-e95e75c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateExcess

func CalculateExcess(
	context *secp256k1.Context,
	tx *core.Transaction,
	fee uint64,
) (
	kernelExcess *secp256k1.Commitment,
	err error,
)

func CommitValue

func CommitValue(value uint64, asset string) uint64

func KernelSignatureMessage

func KernelSignatureMessage(kernel core.TxKernel) []byte

msg = hash(features) for coinbase kernels

hash(features || fee)                for plain kernels
hash(features || fee || lock_height) for height locked kernels

func Parse

func Parse(bytes []byte) (tx *Transaction, issue *Issue, err error)

func PersistIssue

func PersistIssue(issue *Issue, db Database) error

func PersistTransaction

func PersistTransaction(tx *Transaction, db Database, doublespend bool) error

func ValidateIssue

func ValidateIssue(issue *Issue) error

func ValidateState

func ValidateState(outputs []core.Output, kernels []core.TxKernel, assets map[string]uint64) (msg string, err error)

func ValidateTransaction

func ValidateTransaction(ledgerTx *Transaction) (err error)

Types

type Database

type Database interface {
	Begin()
	InputExists(input core.Input) error
	SpendInput(input core.Input) error
	PutOutput(output core.Output) error
	Commit() error
	Close()
	GetOutput(id []byte) (output core.Output, err error)
	ListOutputs() (list []core.Output, err error)
	PutKernel(kernel core.TxKernel) error
	ListKernels() (list []core.TxKernel, err error)
	AddAsset(asset string, value uint64)
	ListAssets() (list map[string]uint64, err error)
	ResetAssets() error
}

type Issue

type Issue struct {
	Output     core.Output   `json:"output"`
	Value      uint64        `json:"value"`
	Asset      string        `json:"asset,omitempty"`
	AssetSig   []byte        `json:"asset_sig,omitempty"`
	IssuerCert []byte        `json:"issue_cert,omitempty"`
	Kernel     core.TxKernel `json:"kernel,omitempty"`
}

func ValidateIssueBytes

func ValidateIssueBytes(issueBytes []byte) (ledgerIssue *Issue, err error)

type Transaction

type Transaction struct {
	core.Transaction
	ID uuid.UUID `json:"id,omitempty"`
}

func ValidateTransactionBytes

func ValidateTransactionBytes(txBytes []byte) (ledgerTx *Transaction, err error)

Jump to

Keyboard shortcuts

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