types

package
v1.1.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TransactionVersionMinterDefinition defines the Transaction version
	// for a MinterDefinition Transaction.
	//
	// See the `MinterDefinitionTransactionController` and `MinterDefinitionTransaction`
	// types for more information.
	TransactionVersionMinterDefinition types.TransactionVersion = iota + 128
	// TransactionVersionCoinCreation defines the Transaction version
	// for a CoinCreation Transaction.
	//
	// See the `CoinCreationTransactionController` and `CoinCreationTransaction`
	// types for more information.
	TransactionVersionCoinCreation
)
View Source
const TransactionNonceLength = 8

TransactionNonceLength defines the length of a TransactionNonce

Variables

View Source
var (
	SpecifierMintDefinitionTransaction = types.Specifier{'m', 'i', 'n', 't', 'e', 'r', ' ', 'd', 'e', 'f', 'i', 'n', ' ', 't', 'x'}
	SpecifierCoinCreationTransaction   = types.Specifier{'c', 'o', 'i', 'n', ' ', 'm', 'i', 'n', 't', ' ', 't', 'x'}
)

These Specifiers are used internally when calculating a Transaction's ID. See Rivine's Specifier for more details.

Functions

func RegisterBlockHeightLimitedMultiSignatureCondition

func RegisterBlockHeightLimitedMultiSignatureCondition(blockHeight types.BlockHeight)

RegisterBlockHeightLimitedMultiSignatureCondition registers the multisig condition, and thus implicitly the fulfillment as well, in a way that it is limited to a certain block height.

func RegisterTransactionTypesForDevNetwork

func RegisterTransactionTypesForDevNetwork(mintConditionGetter MintConditionGetter)

RegisterTransactionTypesForDevNetwork registers he transaction controllers for all transaction versions supported on the dev network.

func RegisterTransactionTypesForStandardNetwork

func RegisterTransactionTypesForStandardNetwork(mintConditionGetter MintConditionGetter)

RegisterTransactionTypesForStandardNetwork registers he transaction controllers for all transaction versions supported on the standard network.

func RegisterTransactionTypesForTestNetwork

func RegisterTransactionTypesForTestNetwork(mintConditionGetter MintConditionGetter)

RegisterTransactionTypesForTestNetwork registers he transaction controllers for all transaction versions supported on the test network.

Types

type CoinCreationTransaction added in v1.1.0

type CoinCreationTransaction struct {
	// Nonce used to ensure the uniqueness of a CoinCreationTransaction's ID and signature.
	Nonce TransactionNonce `json:"nonce"`
	// MintFulfillment defines the fulfillment which is used in order to
	// fulfill the globally defined MintCondition.
	MintFulfillment types.UnlockFulfillmentProxy `json:"mintfulfillment"`
	// CoinOutputs defines the coin outputs,
	// which contain the freshly created coins, adding to the total pool of coins
	// available in the tfchain network.
	CoinOutputs []types.CoinOutput `json:"coinoutputs"`
	// Minerfees, a fee paid for this coin creation transaction.
	MinerFees []types.Currency `json:"minerfees"`
	// ArbitraryData can be used for any purpose,
	// but is mostly to be used in order to define the reason/origins
	// of the coin creation.
	ArbitraryData []byte `json:"arbitrarydata,omitempty"`
}

CoinCreationTransaction is to be created only by the defined Coin Minters, as a medium in order to create coins (coin outputs), without backing them (so without having to spend previously unspend coin outputs, see: coin inputs).

func CoinCreationTransactionFromTransaction added in v1.1.0

func CoinCreationTransactionFromTransaction(tx types.Transaction) (CoinCreationTransaction, error)

CoinCreationTransactionFromTransaction creates a CoinCreationTransaction, using a regular in-memory tfchain transaction.

Past the (tx) Version validation it piggy-backs onto the `CoinCreationTransactionFromTransactionData` constructor.

func CoinCreationTransactionFromTransactionData added in v1.1.0

func CoinCreationTransactionFromTransactionData(txData types.TransactionData) (CoinCreationTransaction, error)

CoinCreationTransactionFromTransactionData creates a CoinCreationTransaction, using the TransactionData from a regular in-memory tfchain transaction.

func (*CoinCreationTransaction) Transaction added in v1.1.0

func (cctx *CoinCreationTransaction) Transaction() types.Transaction

Transaction returns this CoinCreationTransaction as regular tfchain transaction, using TransactionVersionCoinCreation as the type.

func (*CoinCreationTransaction) TransactionData added in v1.1.0

func (cctx *CoinCreationTransaction) TransactionData() types.TransactionData

TransactionData returns this CoinCreationTransaction as regular tfchain transaction data.

type CoinCreationTransactionController added in v1.1.0

type CoinCreationTransactionController struct {
	// MintConditionGetter is used to get a mint condition at the context-defined block height.
	//
	// The found MintCondition defines the condition that has to be fulfilled
	// in order to mint new coins into existence (in the form of non-backed coin outputs).
	MintConditionGetter MintConditionGetter
}

CoinCreationTransactionController defines a tfchain-specific transaction controller, for a transaction type reserved at type 129. It allows for the creation of Coin Outputs, without requiring coin inputs, but can only be used by the defined Coin Minters.

func (CoinCreationTransactionController) DecodeTransactionData added in v1.1.0

func (cctc CoinCreationTransactionController) DecodeTransactionData(r io.Reader) (types.TransactionData, error)

DecodeTransactionData implements TransactionController.DecodeTransactionData

func (CoinCreationTransactionController) EncodeTransactionData added in v1.1.0

func (cctc CoinCreationTransactionController) EncodeTransactionData(w io.Writer, txData types.TransactionData) error

EncodeTransactionData implements TransactionController.EncodeTransactionData

func (CoinCreationTransactionController) EncodeTransactionIDInput added in v1.1.0

func (cctc CoinCreationTransactionController) EncodeTransactionIDInput(w io.Writer, txData types.TransactionData) error

EncodeTransactionIDInput implements TransactionIDEncoder.EncodeTransactionIDInput

func (CoinCreationTransactionController) InputSigHash added in v1.1.0

func (cctc CoinCreationTransactionController) InputSigHash(t types.Transaction, _ uint64, extraObjects ...interface{}) (crypto.Hash, error)

InputSigHash implements InputSigHasher.InputSigHash

func (CoinCreationTransactionController) JSONDecodeTransactionData added in v1.1.0

func (cctc CoinCreationTransactionController) JSONDecodeTransactionData(data []byte) (types.TransactionData, error)

JSONDecodeTransactionData implements TransactionController.JSONDecodeTransactionData

func (CoinCreationTransactionController) JSONEncodeTransactionData added in v1.1.0

func (cctc CoinCreationTransactionController) JSONEncodeTransactionData(txData types.TransactionData) ([]byte, error)

JSONEncodeTransactionData implements TransactionController.JSONEncodeTransactionData

func (CoinCreationTransactionController) SignExtension added in v1.1.0

func (cctc CoinCreationTransactionController) SignExtension(extension interface{}, sign func(*types.UnlockFulfillmentProxy, types.UnlockConditionProxy) error) (interface{}, error)

SignExtension implements TransactionExtensionSigner.SignExtension

func (CoinCreationTransactionController) ValidateBlockStakeOutputs added in v1.1.0

func (cctc CoinCreationTransactionController) ValidateBlockStakeOutputs(t types.Transaction, ctx types.FundValidationContext, blockStakeInputs map[types.BlockStakeOutputID]types.BlockStakeOutput) (err error)

ValidateBlockStakeOutputs implements BlockStakeOutputValidator.ValidateBlockStakeOutputs

func (CoinCreationTransactionController) ValidateCoinOutputs added in v1.1.0

ValidateCoinOutputs implements CoinOutputValidator.ValidateCoinOutputs

func (CoinCreationTransactionController) ValidateTransaction added in v1.1.0

ValidateTransaction implements TransactionValidator.ValidateTransaction

type CoinCreationTransactionExtension added in v1.1.0

type CoinCreationTransactionExtension struct {
	Nonce           TransactionNonce
	MintFulfillment types.UnlockFulfillmentProxy
}

CoinCreationTransactionExtension defines the CoinCreationTx Extension Data

type DefaultTransactionController

type DefaultTransactionController struct {
	types.DefaultTransactionController
	TransactionFeeCheckBlockHeight types.BlockHeight
}

DefaultTransactionController wraps around Rivine's DefaultTransactionController, as to ensure that we use check the MinimumTransactionFee, only since a certain block height, and otherwise just ensure it is bigger than 0.

In order to achieve this, the TransactionValidation interface is implemented on top of the regular DefaultTransactionController.

func (DefaultTransactionController) ValidateTransaction

ValidateTransaction implements TransactionValidator.ValidateTransaction

type LegacyTransactionController

type LegacyTransactionController struct {
	types.LegacyTransactionController
	TransactionFeeCheckBlockHeight types.BlockHeight
}

LegacyTransactionController wraps around Rivine's LegacyTransactionController, as to ensure that we use check the MinimumTransactionFee, only since a certain block height, and otherwise just ensure it is bigger than 0.

In order to achieve this, the TransactionValidation interface is implemented on top of the regular LegacyTransactionController.

func (LegacyTransactionController) ValidateTransaction

ValidateTransaction implements TransactionValidator.ValidateTransaction

type MintConditionGetter added in v1.1.0

type MintConditionGetter interface {
	// GetActiveMintCondition returns the active active mint condition.
	GetActiveMintCondition() (types.UnlockConditionProxy, error)
	// GetMintConditionAt returns the mint condition at a given block height.
	GetMintConditionAt(height types.BlockHeight) (types.UnlockConditionProxy, error)
}

MintConditionGetter allows you to get the mint condition at a given block height.

For the daemon this interface could be implemented directly by the DB object that keeps track of the mint condition state, while for a client this could come via the REST API from a tfchain daemon in a more indirect way.

type MinterDefinitionTransaction added in v1.1.0

type MinterDefinitionTransaction struct {
	// Nonce used to ensure the uniqueness of a MinterDefinitionTransaction's ID and signature.
	Nonce TransactionNonce `json:"nonce"`
	// MintFulfillment defines the fulfillment which is used in order to
	// fulfill the globally defined MintCondition.
	MintFulfillment types.UnlockFulfillmentProxy `json:"mintfulfillment"`
	// MintCondition defines a new condition that defines who become(s) the new minter(s),
	// and thus defines who can create coins as well as update who is/are the current minter(s)
	//
	// UnlockHash (unlockhash type 1) and MultiSigConditions are allowed,
	// as well as TimeLocked conditions which have UnlockHash- and MultiSigConditions as
	// internal condition.
	MintCondition types.UnlockConditionProxy `json:"mintcondition"`
	// Minerfees, a fee paid for this minter definition transaction.
	MinerFees []types.Currency `json:"minerfees"`
	// ArbitraryData can be used for any purpose,
	// but is mostly to be used in order to define the reason/origins
	// of the transfer of minting power.
	ArbitraryData []byte `json:"arbitrarydata,omitempty"`
}

MinterDefinitionTransaction is to be created only by the defined Coin Minters, as a medium in order to transfer minting powers.

func MinterDefinitionTransactionFromTransaction added in v1.1.0

func MinterDefinitionTransactionFromTransaction(tx types.Transaction) (MinterDefinitionTransaction, error)

MinterDefinitionTransactionFromTransaction creates a MinterDefinitionTransaction, using a regular in-memory tfchain transaction.

Past the (tx) Version validation it piggy-backs onto the `MinterDefinitionTransactionFromTransactionData` constructor.

func MinterDefinitionTransactionFromTransactionData added in v1.1.0

func MinterDefinitionTransactionFromTransactionData(txData types.TransactionData) (MinterDefinitionTransaction, error)

MinterDefinitionTransactionFromTransactionData creates a MinterDefinitionTransaction, using the TransactionData from a regular in-memory tfchain transaction.

func (*MinterDefinitionTransaction) Transaction added in v1.1.0

func (cctx *MinterDefinitionTransaction) Transaction() types.Transaction

Transaction returns this CoinCreationTransaction as regular tfchain transaction, using TransactionVersionCoinCreation as the type.

func (*MinterDefinitionTransaction) TransactionData added in v1.1.0

func (cctx *MinterDefinitionTransaction) TransactionData() types.TransactionData

TransactionData returns this CoinCreationTransaction as regular tfchain transaction data.

type MinterDefinitionTransactionController added in v1.1.0

type MinterDefinitionTransactionController struct {
	// MintConditionGetter is used to get a mint condition at the context-defined block height.
	//
	// The found MintCondition defines the condition that has to be fulfilled
	// in order to mint new coins into existence (in the form of non-backed coin outputs).
	MintConditionGetter MintConditionGetter
}

MinterDefinitionTransactionController defines a tfchain-specific transaction controller, for a transaction type reserved at type 128. It allows the transfer of coin minting powers.

func (MinterDefinitionTransactionController) DecodeTransactionData added in v1.1.0

func (mdtc MinterDefinitionTransactionController) DecodeTransactionData(r io.Reader) (types.TransactionData, error)

DecodeTransactionData implements TransactionController.DecodeTransactionData

func (MinterDefinitionTransactionController) EncodeTransactionData added in v1.1.0

func (mdtc MinterDefinitionTransactionController) EncodeTransactionData(w io.Writer, txData types.TransactionData) error

EncodeTransactionData implements TransactionController.EncodeTransactionData

func (MinterDefinitionTransactionController) EncodeTransactionIDInput added in v1.1.0

func (mdtc MinterDefinitionTransactionController) EncodeTransactionIDInput(w io.Writer, txData types.TransactionData) error

EncodeTransactionIDInput implements TransactionIDEncoder.EncodeTransactionIDInput

func (MinterDefinitionTransactionController) InputSigHash added in v1.1.0

func (mdtc MinterDefinitionTransactionController) InputSigHash(t types.Transaction, _ uint64, extraObjects ...interface{}) (crypto.Hash, error)

InputSigHash implements InputSigHasher.InputSigHash

func (MinterDefinitionTransactionController) JSONDecodeTransactionData added in v1.1.0

func (mdtc MinterDefinitionTransactionController) JSONDecodeTransactionData(data []byte) (types.TransactionData, error)

JSONDecodeTransactionData implements TransactionController.JSONDecodeTransactionData

func (MinterDefinitionTransactionController) JSONEncodeTransactionData added in v1.1.0

func (mdtc MinterDefinitionTransactionController) JSONEncodeTransactionData(txData types.TransactionData) ([]byte, error)

JSONEncodeTransactionData implements TransactionController.JSONEncodeTransactionData

func (MinterDefinitionTransactionController) SignExtension added in v1.1.0

func (mdtc MinterDefinitionTransactionController) SignExtension(extension interface{}, sign func(*types.UnlockFulfillmentProxy, types.UnlockConditionProxy) error) (interface{}, error)

SignExtension implements TransactionExtensionSigner.SignExtension

func (MinterDefinitionTransactionController) ValidateBlockStakeOutputs added in v1.1.0

ValidateBlockStakeOutputs implements BlockStakeOutputValidator.ValidateBlockStakeOutputs

func (MinterDefinitionTransactionController) ValidateCoinOutputs added in v1.1.0

ValidateCoinOutputs implements CoinOutputValidator.ValidateCoinOutputs

func (MinterDefinitionTransactionController) ValidateTransaction added in v1.1.0

ValidateTransaction implements TransactionValidator.ValidateTransaction

type MinterDefinitionTransactionExtension added in v1.1.0

type MinterDefinitionTransactionExtension struct {
	Nonce           TransactionNonce
	MintFulfillment types.UnlockFulfillmentProxy
	MintCondition   types.UnlockConditionProxy
}

MinterDefinitionTransactionExtension defines the MinterDefinitionTx Extension Data

type MultiSignatureCondition

type MultiSignatureCondition struct {
	types.MultiSignatureCondition
	// contains filtered or unexported fields
}

MultiSignatureCondition wraps around the Rivine-standard MultiSignatureCondition type, as to ensure that in the standard network of tfchain, it can only be used since blockheight 42000

func (MultiSignatureCondition) Equal

Equal implements UnlockCondition.Equal, ensuring the equality works for any expected MultiSig Combination.

func (MultiSignatureCondition) IsStandardCondition

func (msc MultiSignatureCondition) IsStandardCondition(ctx types.ValidationContext) error

IsStandardCondition implements UnlockCondition.IsStandardCondition, wrapping around the internal MultiSignatureCondition's IsStandardCondition check, adding a pre-check of the blockheight

type TransactionNonce added in v1.1.0

type TransactionNonce [TransactionNonceLength]byte

TransactionNonce is a nonce used to ensure the uniqueness of an otherwise potentially non-unique Tx

func RandomTransactionNonce added in v1.1.0

func RandomTransactionNonce() (nonce TransactionNonce)

RandomTransactionNonce creates a random Transaction nonce

func (TransactionNonce) MarshalJSON added in v1.1.0

func (tn TransactionNonce) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON.Marshaller.MarshalJSON encodes the Nonce as a base64-encoded string

func (*TransactionNonce) UnmarshalJSON added in v1.1.0

func (tn *TransactionNonce) UnmarshalJSON(in []byte) error

UnmarshalJSON implements JSON.Unmarshaller.UnmarshalJSON piggy-backing on the base64-decoding used for byte slices in the std JSON lib

Jump to

Keyboard shortcuts

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