txs

package
v1.7.17 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package txs is a generated GoMock package.

Index

Constants

View Source
const (
	MaxNameLen    = 128
	MaxGenesisLen = units.MiB
)
View Source
const Version = 0

Version is the current default codec version

Variables

Codec does serialization and deserialization

View Source
var (
	ErrCantValidatePrimaryNetwork = errors.New("new blockchain can't be validated by primary network")
)
View Source
var (
	ErrNilTx = errors.New("tx is nil")
)
View Source
var (
	ErrWrongLocktime = errors.New("wrong locktime reported")
)

Functions

func RegisterUnsignedTxsTypes

func RegisterUnsignedTxsTypes(targetCodec codec.Registry) error

RegisterUnsignedTxsTypes allows registering relevant type of unsigned package in the right sequence. Following repackaging of platformvm package, a few subpackage-level codecs were introduced, each handling serialization of specific types. RegisterUnsignedTxsTypes is made exportable so to guarantee that other codecs are coherent with components one.

Types

type AddDelegatorTx

type AddDelegatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Describes the delegatee
	Validator validator.Validator `serialize:"true" json:"validator"`
	// Where to send staked tokens when done validating
	Stake []*avax.TransferableOutput `serialize:"true" json:"stake"`
	// Where to send staking rewards when done validating
	RewardsOwner fx.Owner `serialize:"true" json:"rewardsOwner"`
}

AddDelegatorTx is an unsigned addDelegatorTx

func (*AddDelegatorTx) EndTime

func (tx *AddDelegatorTx) EndTime() time.Time

EndTime of this validator

func (*AddDelegatorTx) InitCtx

func (tx *AddDelegatorTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this [UnsignedAddDelegatorTx]. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*AddDelegatorTx) StartTime

func (tx *AddDelegatorTx) StartTime() time.Time

StartTime of this validator

func (*AddDelegatorTx) SyntacticVerify

func (tx *AddDelegatorTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify returns nil iff [tx] is valid

func (*AddDelegatorTx) Visit

func (tx *AddDelegatorTx) Visit(visitor Visitor) error

func (*AddDelegatorTx) Weight

func (tx *AddDelegatorTx) Weight() uint64

Weight of this validator

type AddSubnetValidatorTx

type AddSubnetValidatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// The validator
	Validator validator.SubnetValidator `serialize:"true" json:"validator"`
	// Auth that will be allowing this validator into the network
	SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}

AddSubnetValidatorTx is an unsigned addSubnetValidatorTx

func (*AddSubnetValidatorTx) EndTime

func (tx *AddSubnetValidatorTx) EndTime() time.Time

EndTime of this validator

func (*AddSubnetValidatorTx) StartTime

func (tx *AddSubnetValidatorTx) StartTime() time.Time

StartTime of this validator

func (*AddSubnetValidatorTx) SyntacticVerify

func (tx *AddSubnetValidatorTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify returns nil iff [tx] is valid

func (*AddSubnetValidatorTx) Visit

func (tx *AddSubnetValidatorTx) Visit(visitor Visitor) error

func (*AddSubnetValidatorTx) Weight

func (tx *AddSubnetValidatorTx) Weight() uint64

Weight of this validator

type AddValidatorTx

type AddValidatorTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Describes the delegatee
	Validator validator.Validator `serialize:"true" json:"validator"`
	// Where to send staked tokens when done validating
	Stake []*avax.TransferableOutput `serialize:"true" json:"stake"`
	// Where to send staking rewards when done validating
	RewardsOwner fx.Owner `serialize:"true" json:"rewardsOwner"`
	// Fee this validator charges delegators as a percentage, times 10,000
	// For example, if this validator has Shares=300,000 then they take 30% of rewards from delegators
	Shares uint32 `serialize:"true" json:"shares"`
}

AddValidatorTx is an unsigned addValidatorTx

func (*AddValidatorTx) EndTime

func (tx *AddValidatorTx) EndTime() time.Time

EndTime of this validator

func (*AddValidatorTx) InitCtx

func (tx *AddValidatorTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this AddValidatorTx. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*AddValidatorTx) StartTime

func (tx *AddValidatorTx) StartTime() time.Time

StartTime of this validator

func (*AddValidatorTx) SyntacticVerify

func (tx *AddValidatorTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify returns nil iff [tx] is valid

func (*AddValidatorTx) Visit

func (tx *AddValidatorTx) Visit(visitor Visitor) error

func (*AddValidatorTx) Weight

func (tx *AddValidatorTx) Weight() uint64

Weight of this validator

type AdvanceTimeTx

type AdvanceTimeTx struct {
	// Unix time this block proposes increasing the timestamp to
	Time uint64 `serialize:"true" json:"time"`
	// contains filtered or unexported fields
}

AdvanceTimeTx is a transaction to increase the chain's timestamp. When the chain's timestamp is updated (a AdvanceTimeTx is accepted and followed by a commit block) the staker set is also updated accordingly. It must be that: - proposed timestamp > [current chain time] - proposed timestamp <= [time for next staker set change]

func (*AdvanceTimeTx) Bytes

func (tx *AdvanceTimeTx) Bytes() []byte

func (*AdvanceTimeTx) InitCtx

func (tx *AdvanceTimeTx) InitCtx(*snow.Context)

func (*AdvanceTimeTx) Initialize

func (tx *AdvanceTimeTx) Initialize(unsignedBytes []byte)

func (*AdvanceTimeTx) InputIDs

func (tx *AdvanceTimeTx) InputIDs() ids.Set

func (*AdvanceTimeTx) Outputs

func (tx *AdvanceTimeTx) Outputs() []*avax.TransferableOutput

func (*AdvanceTimeTx) SyntacticVerify

func (tx *AdvanceTimeTx) SyntacticVerify(*snow.Context) error

func (*AdvanceTimeTx) Timestamp

func (tx *AdvanceTimeTx) Timestamp() time.Time

Timestamp returns the time this block is proposing the chain should be set to

func (*AdvanceTimeTx) Visit

func (tx *AdvanceTimeTx) Visit(visitor Visitor) error

type BaseTx

type BaseTx struct {
	avax.BaseTx `serialize:"true"`

	// true iff this transaction has already passed syntactic verification
	SyntacticallyVerified bool
	// contains filtered or unexported fields
}

BaseTx contains fields common to many transaction types. It should be embedded in transaction implementations.

func (*BaseTx) Bytes

func (tx *BaseTx) Bytes() []byte

func (*BaseTx) InitCtx

func (tx *BaseTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this BaseTx. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*BaseTx) Initialize

func (tx *BaseTx) Initialize(unsignedBytes []byte)

func (*BaseTx) InputIDs

func (tx *BaseTx) InputIDs() ids.Set

func (*BaseTx) Outputs

func (tx *BaseTx) Outputs() []*avax.TransferableOutput

func (*BaseTx) SyntacticVerify

func (tx *BaseTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify returns nil iff this tx is well formed

type CreateChainTx

type CreateChainTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// ID of the Subnet that validates this blockchain
	SubnetID ids.ID `serialize:"true" json:"subnetID"`
	// A human readable name for the chain; need not be unique
	ChainName string `serialize:"true" json:"chainName"`
	// ID of the VM running on the new chain
	VMID ids.ID `serialize:"true" json:"vmID"`
	// IDs of the feature extensions running on the new chain
	FxIDs []ids.ID `serialize:"true" json:"fxIDs"`
	// Byte representation of genesis state of the new chain
	GenesisData []byte `serialize:"true" json:"genesisData"`
	// Authorizes this blockchain to be added to this subnet
	SubnetAuth verify.Verifiable `serialize:"true" json:"subnetAuthorization"`
}

CreateChainTx is an unsigned createChainTx

func (*CreateChainTx) SyntacticVerify

func (tx *CreateChainTx) SyntacticVerify(ctx *snow.Context) error

func (*CreateChainTx) Visit

func (tx *CreateChainTx) Visit(visitor Visitor) error

type CreateSubnetTx

type CreateSubnetTx struct {
	// Metadata, inputs and outputs
	BaseTx `serialize:"true"`
	// Who is authorized to manage this subnet
	Owner fx.Owner `serialize:"true" json:"owner"`
}

CreateSubnetTx is an unsigned proposal to create a new subnet

func (*CreateSubnetTx) InitCtx

func (tx *CreateSubnetTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this CreateSubnetTx. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*CreateSubnetTx) SyntacticVerify

func (tx *CreateSubnetTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify verifies that this transaction is well-formed

func (*CreateSubnetTx) Visit

func (tx *CreateSubnetTx) Visit(visitor Visitor) error

type ExportTx

type ExportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to send the funds to
	DestinationChain ids.ID `serialize:"true" json:"destinationChain"`

	// Outputs that are exported to the chain
	ExportedOutputs []*avax.TransferableOutput `serialize:"true" json:"exportedOutputs"`
}

ExportTx is an unsigned exportTx

func (*ExportTx) InitCtx

func (tx *ExportTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this [UnsignedExportTx]. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*ExportTx) SyntacticVerify

func (tx *ExportTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify this transaction is well-formed

func (*ExportTx) Visit

func (tx *ExportTx) Visit(visitor Visitor) error

type ImportTx

type ImportTx struct {
	BaseTx `serialize:"true"`

	// Which chain to consume the funds from
	SourceChain ids.ID `serialize:"true" json:"sourceChain"`

	// Inputs that consume UTXOs produced on the chain
	ImportedInputs []*avax.TransferableInput `serialize:"true" json:"importedInputs"`
}

ImportTx is an unsigned importTx

func (*ImportTx) InitCtx

func (tx *ImportTx) InitCtx(ctx *snow.Context)

InitCtx sets the FxID fields in the inputs and outputs of this ImportTx. Also sets the [ctx] to the given [vm.ctx] so that the addresses can be json marshalled into human readable format

func (*ImportTx) InputIDs

func (tx *ImportTx) InputIDs() ids.Set

func (*ImportTx) InputUTXOs

func (tx *ImportTx) InputUTXOs() ids.Set

InputUTXOs returns the UTXOIDs of the imported funds

func (*ImportTx) SyntacticVerify

func (tx *ImportTx) SyntacticVerify(ctx *snow.Context) error

SyntacticVerify this transaction is well-formed

func (*ImportTx) Visit

func (tx *ImportTx) Visit(visitor Visitor) error

type MockUnsignedTx

type MockUnsignedTx struct {
	// contains filtered or unexported fields
}

MockUnsignedTx is a mock of UnsignedTx interface

func NewMockUnsignedTx

func NewMockUnsignedTx(ctrl *gomock.Controller) *MockUnsignedTx

NewMockUnsignedTx creates a new mock instance

func (*MockUnsignedTx) Bytes

func (m *MockUnsignedTx) Bytes() []byte

Bytes mocks base method

func (*MockUnsignedTx) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockUnsignedTx) InitCtx

func (m *MockUnsignedTx) InitCtx(arg0 *snow.Context)

InitCtx mocks base method

func (*MockUnsignedTx) Initialize

func (m *MockUnsignedTx) Initialize(arg0 []byte)

Initialize mocks base method

func (*MockUnsignedTx) InputIDs

func (m *MockUnsignedTx) InputIDs() ids.Set

InputIDs mocks base method

func (*MockUnsignedTx) Outputs

func (m *MockUnsignedTx) Outputs() []*avax.TransferableOutput

Outputs mocks base method

func (*MockUnsignedTx) SyntacticVerify

func (m *MockUnsignedTx) SyntacticVerify(arg0 *snow.Context) error

SyntacticVerify mocks base method

func (*MockUnsignedTx) Visit

func (m *MockUnsignedTx) Visit(arg0 Visitor) error

Visit mocks base method

type MockUnsignedTxMockRecorder

type MockUnsignedTxMockRecorder struct {
	// contains filtered or unexported fields
}

MockUnsignedTxMockRecorder is the mock recorder for MockUnsignedTx

func (*MockUnsignedTxMockRecorder) Bytes

func (mr *MockUnsignedTxMockRecorder) Bytes() *gomock.Call

Bytes indicates an expected call of Bytes

func (*MockUnsignedTxMockRecorder) InitCtx

func (mr *MockUnsignedTxMockRecorder) InitCtx(arg0 interface{}) *gomock.Call

InitCtx indicates an expected call of InitCtx

func (*MockUnsignedTxMockRecorder) Initialize

func (mr *MockUnsignedTxMockRecorder) Initialize(arg0 interface{}) *gomock.Call

Initialize indicates an expected call of Initialize

func (*MockUnsignedTxMockRecorder) InputIDs

func (mr *MockUnsignedTxMockRecorder) InputIDs() *gomock.Call

InputIDs indicates an expected call of InputIDs

func (*MockUnsignedTxMockRecorder) Outputs

func (mr *MockUnsignedTxMockRecorder) Outputs() *gomock.Call

Outputs indicates an expected call of Outputs

func (*MockUnsignedTxMockRecorder) SyntacticVerify

func (mr *MockUnsignedTxMockRecorder) SyntacticVerify(arg0 interface{}) *gomock.Call

SyntacticVerify indicates an expected call of SyntacticVerify

func (*MockUnsignedTxMockRecorder) Visit

func (mr *MockUnsignedTxMockRecorder) Visit(arg0 interface{}) *gomock.Call

Visit indicates an expected call of Visit

type RewardValidatorTx

type RewardValidatorTx struct {
	// ID of the tx that created the delegator/validator being removed/rewarded
	TxID ids.ID `serialize:"true" json:"txID"`

	// Marks if this validator should be rewarded according to this node.
	ShouldPreferCommit bool
	// contains filtered or unexported fields
}

RewardValidatorTx is a transaction that represents a proposal to remove a validator that is currently validating from the validator set.

If this transaction is accepted and the next block accepted is a Commit block, the validator is removed and the address that the validator specified receives the staked AVAX as well as a validating reward.

If this transaction is accepted and the next block accepted is an Abort block, the validator is removed and the address that the validator specified receives the staked AVAX but no reward.

func (*RewardValidatorTx) Bytes

func (tx *RewardValidatorTx) Bytes() []byte

func (*RewardValidatorTx) InitCtx

func (tx *RewardValidatorTx) InitCtx(*snow.Context)

func (*RewardValidatorTx) Initialize

func (tx *RewardValidatorTx) Initialize(unsignedBytes []byte)

func (*RewardValidatorTx) InputIDs

func (tx *RewardValidatorTx) InputIDs() ids.Set

func (*RewardValidatorTx) Outputs

func (tx *RewardValidatorTx) Outputs() []*avax.TransferableOutput

func (*RewardValidatorTx) SyntacticVerify

func (tx *RewardValidatorTx) SyntacticVerify(*snow.Context) error

func (*RewardValidatorTx) Visit

func (tx *RewardValidatorTx) Visit(visitor Visitor) error

type StakerTx

type StakerTx interface {
	UnsignedTx

	StartTime() time.Time
	EndTime() time.Time
	Weight() uint64
}

type Tx

type Tx struct {
	// The body of this transaction
	Unsigned UnsignedTx `serialize:"true" json:"unsignedTx"`

	// The credentials of this transaction
	Creds []verify.Verifiable `serialize:"true" json:"credentials"`
	// contains filtered or unexported fields
}

Tx is a signed transaction

func NewSigned

func NewSigned(
	unsigned UnsignedTx,
	c codec.Manager,
	signers [][]*crypto.PrivateKeySECP256K1R,
) (*Tx, error)

func Parse

func Parse(c codec.Manager, signedBytes []byte) (*Tx, error)

Parse signed tx starting from its byte representation

func (*Tx) Bytes

func (tx *Tx) Bytes() []byte

func (*Tx) ID

func (tx *Tx) ID() ids.ID

func (*Tx) Initialize

func (tx *Tx) Initialize(unsignedBytes, signedBytes []byte)

func (*Tx) Sign

func (tx *Tx) Sign(c codec.Manager, signers [][]*crypto.PrivateKeySECP256K1R) error

Sign this transaction with the provided signers

func (*Tx) SyntacticVerify

func (tx *Tx) SyntacticVerify(ctx *snow.Context) error

func (*Tx) UTXOs

func (tx *Tx) UTXOs() []*avax.UTXO

UTXOs returns the UTXOs transaction is producing.

type UnsignedTx

type UnsignedTx interface {
	// TODO: Remove this initialization pattern from both the platformvm and the
	// avm.
	snow.ContextInitializable
	Initialize(unsignedBytes []byte)
	Bytes() []byte

	// InputIDs returns the set of inputs this transaction consumes
	InputIDs() ids.Set

	Outputs() []*avax.TransferableOutput

	// Attempts to verify this transaction without any provided state.
	SyntacticVerify(ctx *snow.Context) error

	// Visit calls [visitor] with this transaction's concrete type
	Visit(visitor Visitor) error
}

UnsignedTx is an unsigned transaction

type Visitor

type Visitor interface {
	AddValidatorTx(*AddValidatorTx) error
	AddSubnetValidatorTx(*AddSubnetValidatorTx) error
	AddDelegatorTx(*AddDelegatorTx) error
	CreateChainTx(*CreateChainTx) error
	CreateSubnetTx(*CreateSubnetTx) error
	ImportTx(*ImportTx) error
	ExportTx(*ExportTx) error
	AdvanceTimeTx(*AdvanceTimeTx) error
	RewardValidatorTx(*RewardValidatorTx) error
}

Allow vm to execute custom logic against the underlying transaction types.

Directories

Path Synopsis
Package mempool is a generated GoMock package.
Package mempool is a generated GoMock package.

Jump to

Keyboard shortcuts

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