utxo

package
v1.8.0-rc.13 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: BSD-3-Clause Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Consume

func Consume(utxoDB state.UTXODeleter, ins []*avax.TransferableInput)

Removes the UTXOs consumed by [ins] from the UTXO set

func Produce

func Produce(
	utxoDB state.UTXOAdder,
	txID ids.ID,
	outs []*avax.TransferableOutput,
)

Adds the UTXOs created by [outs] to the UTXO set. [txID] is the ID of the tx that created [outs].

Types

type Handler

type Handler interface {
	Spender
	Verifier
}

func NewHandler

func NewHandler(
	ctx *snow.Context,
	clk *mockable.Clock,
	utxoReader avax.UTXOReader,
	fx fx.Fx,
) Handler

type Spender

type Spender interface {
	// Spend the provided amount while deducting the provided fee.
	// Arguments:
	// - [keys] are the owners of the funds
	// - [amount] is the amount of funds that are trying to be staked
	// - [fee] is the amount of AVAX that should be burned
	// - [changeAddr] is the address that change, if there is any, is sent to
	// Returns:
	// - [inputs] the inputs that should be consumed to fund the outputs
	// - [returnedOutputs] the outputs that should be immediately returned to
	//                     the UTXO set
	// - [stakedOutputs] the outputs that should be locked for the duration of
	//                   the staking period
	// - [signers] the proof of ownership of the funds being moved
	Spend(
		keys []*crypto.PrivateKeySECP256K1R,
		amount uint64,
		fee uint64,
		changeAddr ids.ShortID,
	) (
		[]*avax.TransferableInput,
		[]*avax.TransferableOutput,
		[]*avax.TransferableOutput,
		[][]*crypto.PrivateKeySECP256K1R,
		error,
	)

	// Authorize an operation on behalf of the named subnet with the provided
	// keys.
	Authorize(
		state state.Chain,
		subnetID ids.ID,
		keys []*crypto.PrivateKeySECP256K1R,
	) (
		verify.Verifiable,
		[]*crypto.PrivateKeySECP256K1R,
		error,
	)
}

TODO: Stake and Authorize should be replaced by similar methods in the

P-chain wallet

type Verifier

type Verifier interface {
	// Verify that [tx] is semantically valid.
	// [ins] and [outs] are the inputs and outputs of [tx].
	// [creds] are the credentials of [tx], which allow [ins] to be spent.
	// [unlockedProduced] is the map of assets that were produced and their
	// amounts.
	// The [ins] must have at least [unlockedProduced] than the [outs].
	//
	// Precondition: [tx] has already been syntactically verified.
	//
	// Note: [unlockedProduced] is modified by this method.
	VerifySpend(
		tx txs.UnsignedTx,
		utxoDB state.UTXOGetter,
		ins []*avax.TransferableInput,
		outs []*avax.TransferableOutput,
		creds []verify.Verifiable,
		unlockedProduced map[ids.ID]uint64,
	) error

	// Verify that [tx] is semantically valid.
	// [utxos[i]] is the UTXO being consumed by [ins[i]].
	// [ins] and [outs] are the inputs and outputs of [tx].
	// [creds] are the credentials of [tx], which allow [ins] to be spent.
	// [unlockedProduced] is the map of assets that were produced and their
	// amounts.
	// The [ins] must have at least [unlockedProduced] more than the [outs].
	//
	// Precondition: [tx] has already been syntactically verified.
	//
	// Note: [unlockedProduced] is modified by this method.
	VerifySpendUTXOs(
		tx txs.UnsignedTx,
		utxos []*avax.UTXO,
		ins []*avax.TransferableInput,
		outs []*avax.TransferableOutput,
		creds []verify.Verifiable,
		unlockedProduced map[ids.ID]uint64,
	) error
}

Jump to

Keyboard shortcuts

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