Documentation ¶
Index ¶
- Constants
- func GetBalance(db UTXOReader, addrs ids.ShortSet) (uint64, error)
- func IsSortedAndUniqueTransferableInputs(ins []*TransferableInput) bool
- func IsSortedAndUniqueTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R) bool
- func IsSortedAndUniqueUTXOIDs(utxos []*UTXOID) bool
- func IsSortedTransferableOutputs(outs []*TransferableOutput, c codec.Manager) bool
- func ParseLocalAddresses(a AddressManager, addrStrs []string) (ids.ShortSet, error)
- func SortTransferableInputs(ins []*TransferableInput)
- func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R)
- func SortTransferableOutputs(outs []*TransferableOutput, c codec.Manager)
- func SortUTXOIDs(utxos []*UTXOID)
- func VerifyTx(feeAmount uint64, feeAssetID ids.ID, allIns [][]*TransferableInput, ...) error
- type AddressManager
- type Addressable
- type Amounter
- type Asset
- type AtomicUTXOManager
- type BaseTx
- type Coster
- type FlowChecker
- type Metadata
- type SingletonState
- type StatusState
- type TestAddressable
- type TestTransferable
- type TestVerifiable
- type TransferableIn
- type TransferableInput
- type TransferableOut
- type TransferableOutput
- type UTXO
- type UTXOGetter
- type UTXOID
- type UTXOReader
- type UTXOState
- type UTXOWriter
Constants ¶
const (
IsInitializedKey byte = iota
)
const MaxMemoSize = 256
MaxMemoSize is the maximum number of bytes in the memo field
Variables ¶
This section is empty.
Functions ¶
func GetBalance ¶ added in v1.7.4
func GetBalance(db UTXOReader, addrs ids.ShortSet) (uint64, error)
GetBalance returns the current balance of [addrs]
func IsSortedAndUniqueTransferableInputs ¶
func IsSortedAndUniqueTransferableInputs(ins []*TransferableInput) bool
func IsSortedAndUniqueTransferableInputsWithSigners ¶
func IsSortedAndUniqueTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R) bool
IsSortedAndUniqueTransferableInputsWithSigners returns true if the inputs are sorted and unique
func IsSortedTransferableOutputs ¶
func IsSortedTransferableOutputs(outs []*TransferableOutput, c codec.Manager) bool
IsSortedTransferableOutputs returns true if output objects are sorted
func ParseLocalAddresses ¶ added in v1.7.4
func ParseLocalAddresses(a AddressManager, addrStrs []string) (ids.ShortSet, error)
func SortTransferableInputs ¶
func SortTransferableInputs(ins []*TransferableInput)
func SortTransferableInputsWithSigners ¶
func SortTransferableInputsWithSigners(ins []*TransferableInput, signers [][]*crypto.PrivateKeySECP256K1R)
SortTransferableInputsWithSigners sorts the inputs and signers based on the input's utxo ID
func SortTransferableOutputs ¶
func SortTransferableOutputs(outs []*TransferableOutput, c codec.Manager)
SortTransferableOutputs sorts output objects
func SortUTXOIDs ¶
func SortUTXOIDs(utxos []*UTXOID)
func VerifyTx ¶
func VerifyTx( feeAmount uint64, feeAssetID ids.ID, allIns [][]*TransferableInput, allOuts [][]*TransferableOutput, c codec.Manager, ) error
VerifyTx verifies that the inputs and outputs flowcheck, including a fee. Additionally, this verifies that the inputs and outputs are sorted.
Types ¶
type AddressManager ¶ added in v1.4.5
type AddressManager interface { // ParseLocalAddress takes in an address for this chain and produces the ID ParseLocalAddress(addrStr string) (ids.ShortID, error) // ParseAddress takes in an address and produces the ID of the chain it's // for and the ID of the address ParseAddress(addrStr string) (ids.ID, ids.ShortID, error) // FormatLocalAddress takes in a raw address and produces the formatted // address for this chain FormatLocalAddress(addr ids.ShortID) (string, error) // FormatAddress takes in a chainID and a raw address and produces the // formatted address for that chain FormatAddress(chainID ids.ID, addr ids.ShortID) (string, error) }
func NewAddressManager ¶ added in v1.4.5
func NewAddressManager(ctx *snow.Context) AddressManager
type Addressable ¶
type Addressable interface {
Addresses() [][]byte
}
Addressable is the interface a feature extension must provide to be able to be tracked as a part of the utxo set for a set of addresses
type Amounter ¶
type Amounter interface { snow.ContextInitializable // Amount returns how much value this element represents of the asset in its // transaction. Amount() uint64 }
Amounter is a data structure that has an amount of something associated with it
type AtomicUTXOManager ¶ added in v1.4.5
type AtomicUTXOManager interface { // GetAtomicUTXOs returns exported UTXOs such that at least one of the // addresses in [addrs] is referenced. // // Returns at most [limit] UTXOs. // // Returns: // * The fetched UTXOs // * The address associated with the last UTXO fetched // * The ID of the last UTXO fetched // * Any error that may have occurred upstream. GetAtomicUTXOs( chainID ids.ID, addrs ids.ShortSet, startAddr ids.ShortID, startUTXOID ids.ID, limit int, ) ([]*UTXO, ids.ShortID, ids.ID, error) }
func NewAtomicUTXOManager ¶ added in v1.4.5
func NewAtomicUTXOManager(sm atomic.SharedMemory, codec codec.Manager) AtomicUTXOManager
type BaseTx ¶
type BaseTx struct { Metadata NetworkID uint32 `serialize:"true" json:"networkID"` // ID of the network this chain lives on BlockchainID ids.ID `serialize:"true" json:"blockchainID"` // ID of the chain on which this transaction exists (prevents replay attacks) Outs []*TransferableOutput `serialize:"true" json:"outputs"` // The outputs of this transaction Ins []*TransferableInput `serialize:"true" json:"inputs"` // The inputs to this transaction Memo types.JSONByteSlice `serialize:"true" json:"memo"` // Memo field contains arbitrary bytes, up to maxMemoSize }
BaseTx is the basis of all standard transactions.
func (*BaseTx) ConsumedAssetIDs ¶
ConsumedAssetIDs returns the IDs of the assets this transaction consumes
func (*BaseTx) InputUTXOs ¶
InputUTXOs track which UTXOs this transaction is consuming.
func (*BaseTx) MetadataVerify ¶
MetadataVerify ensures that transaction metadata is valid
func (*BaseTx) NumCredentials ¶
NumCredentials returns the number of expected credentials
type Coster ¶ added in v1.5.0
type Coster interface { // Cost returns how much this element costs to be included in its // transaction. Cost() (uint64, error) }
Coster is a data structure that has a cost associated with it
type FlowChecker ¶
type FlowChecker struct {
// contains filtered or unexported fields
}
func NewFlowChecker ¶
func NewFlowChecker() *FlowChecker
func (*FlowChecker) Verify ¶
func (fc *FlowChecker) Verify() error
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
func (*Metadata) Initialize ¶
Initialize set the bytes and ID
func (*Metadata) UnsignedBytes ¶
UnsignedBytes returns the unsigned binary representation of this data
type SingletonState ¶ added in v1.4.5
SingletonState is a thin wrapper around a database to provide, caching, serialization, and de-serialization of singletons.
func NewSingletonState ¶ added in v1.4.5
func NewSingletonState(db database.Database) SingletonState
type StatusState ¶ added in v1.4.5
type StatusState interface { // Status returns a status from storage. GetStatus(id ids.ID) (choices.Status, error) // PutStatus saves a status in storage. PutStatus(id ids.ID, status choices.Status) error // DeleteStatus removes a status from storage. DeleteStatus(id ids.ID) error }
StatusState is a thin wrapper around a database to provide, caching, serialization, and de-serialization for statuses.
func NewMeteredStatusState ¶ added in v1.4.5
func NewMeteredStatusState(db database.Database, metrics prometheus.Registerer) (StatusState, error)
func NewStatusState ¶ added in v1.4.5
func NewStatusState(db database.Database) StatusState
type TestAddressable ¶
type TestAddressable struct { TestTransferable `serialize:"true"` Addrs [][]byte `serialize:"true"` }
func (*TestAddressable) Addresses ¶
func (a *TestAddressable) Addresses() [][]byte
type TestTransferable ¶
type TestTransferable struct { TestVerifiable Val uint64 `serialize:"true"` }
func (*TestTransferable) Amount ¶
func (t *TestTransferable) Amount() uint64
func (*TestTransferable) Cost ¶ added in v1.5.0
func (t *TestTransferable) Cost() (uint64, error)
func (*TestTransferable) InitCtx ¶ added in v1.4.12
func (t *TestTransferable) InitCtx(*snow.Context)
type TestVerifiable ¶
type TestVerifiable struct{ Err error }
func (*TestVerifiable) InitCtx ¶ added in v1.4.12
func (v *TestVerifiable) InitCtx(ctx *snow.Context)
func (*TestVerifiable) Verify ¶
func (v *TestVerifiable) Verify() error
func (*TestVerifiable) VerifyState ¶
func (v *TestVerifiable) VerifyState() error
type TransferableIn ¶
type TransferableIn interface { verify.Verifiable Amounter Coster }
TransferableIn is the interface a feature extension must provide to transfer value between features extensions.
type TransferableInput ¶
type TransferableInput struct { UTXOID `serialize:"true"` Asset `serialize:"true"` // FxID has serialize false because we don't want this to be encoded in bytes FxID ids.ID `serialize:"false" json:"fxID"` In TransferableIn `serialize:"true" json:"input"` }
func (*TransferableInput) Input ¶
func (in *TransferableInput) Input() TransferableIn
Input returns the feature extension input that this Input is using.
func (*TransferableInput) Verify ¶
func (in *TransferableInput) Verify() error
type TransferableOut ¶
type TransferableOut interface { snow.ContextInitializable verify.State Amounter }
TransferableOut is the interface a feature extension must provide to transfer value between features extensions.
type TransferableOutput ¶
type TransferableOutput struct { Asset `serialize:"true"` // FxID has serialize false because we don't want this to be encoded in bytes FxID ids.ID `serialize:"false" json:"fxID"` Out TransferableOut `serialize:"true" json:"output"` }
func (*TransferableOutput) InitCtx ¶ added in v1.4.12
func (out *TransferableOutput) InitCtx(ctx *snow.Context)
func (*TransferableOutput) Output ¶
func (out *TransferableOutput) Output() TransferableOut
Output returns the feature extension output that this Output is using.
func (*TransferableOutput) Verify ¶
func (out *TransferableOutput) Verify() error
type UTXO ¶
type UTXO struct { UTXOID `serialize:"true"` Asset `serialize:"true"` Out verify.State `serialize:"true" json:"output"` }
func GetAllUTXOs ¶ added in v1.7.4
func GetAllUTXOs(db UTXOReader, addrs ids.ShortSet) ([]*UTXO, error)
func GetPaginatedUTXOs ¶ added in v1.7.4
func GetPaginatedUTXOs( db UTXOReader, addrs ids.ShortSet, lastAddr ids.ShortID, lastUTXOID ids.ID, limit int, ) ([]*UTXO, ids.ShortID, ids.ID, error)
GetPaginatedUTXOs returns UTXOs such that at least one of the addresses in [addrs] is referenced.
Returns at most [limit] UTXOs.
Only returns UTXOs associated with addresses >= [startAddr].
For address [startAddr], only returns UTXOs whose IDs are greater than [startUTXOID].
Returns: * The fetched UTXOs * The address associated with the last UTXO fetched * The ID of the last UTXO fetched
type UTXOGetter ¶ added in v1.7.6
type UTXOGetter interface { // GetUTXO attempts to load a utxo. GetUTXO(utxoID ids.ID) (*UTXO, error) }
UTXOGetter is a thin wrapper around a database to provide fetching of a UTXO.
type UTXOID ¶
type UTXOID struct { // Serialized: TxID ids.ID `serialize:"true" json:"txID"` OutputIndex uint32 `serialize:"true" json:"outputIndex"` // Symbol is false if the UTXO should be part of the DB Symbol bool `json:"-"` // contains filtered or unexported fields }
func (*UTXOID) InputSource ¶
InputSource returns the source of the UTXO that this input is spending
type UTXOReader ¶ added in v1.7.4
type UTXOReader interface { UTXOGetter // UTXOIDs returns the slice of IDs associated with [addr], starting after // [previous]. // If [previous] is not in the list, starts at beginning. // Returns at most [limit] IDs. UTXOIDs(addr []byte, previous ids.ID, limit int) ([]ids.ID, error) }
UTXOReader is a thin wrapper around a database to provide fetching of UTXOs.
type UTXOState ¶ added in v1.4.5
type UTXOState interface { UTXOReader UTXOWriter }
UTXOState is a thin wrapper around a database to provide, caching, serialization, and de-serialization for UTXOs.
func NewMeteredUTXOState ¶ added in v1.4.5
func NewMeteredUTXOState(db database.Database, codec codec.Manager, metrics prometheus.Registerer) (UTXOState, error)
type UTXOWriter ¶ added in v1.7.4
type UTXOWriter interface { // PutUTXO saves the provided utxo to storage. PutUTXO(utxoID ids.ID, utxo *UTXO) error // DeleteUTXO deletes the provided utxo. DeleteUTXO(utxoID ids.ID) error }
UTXOWriter is a thin wrapper around a database to provide storage and deletion of UTXOs.