Documentation ¶
Index ¶
- Variables
- type APIAccount
- type Account
- func (a Account) Balance() uint64
- func (a Account) CreateTx(amount uint64, destination ids.ShortID, ctx *snow.Context, ...) (*Tx, Account, error)
- func (a Account) ID() ids.ShortID
- func (a Account) Nonce() uint64
- func (a Account) Receive(tx *Tx, ctx *snow.Context) (Account, error)
- func (a Account) Send(tx *Tx, ctx *snow.Context) (Account, error)
- func (a Account) String() string
- func (a Account) Verify() error
- func (a Account) VerifyReceive(tx *Tx, ctx *snow.Context) error
- func (a Account) VerifySend(tx *Tx, ctx *snow.Context) error
- type Block
- type BuildGenesisArgs
- type BuildGenesisReply
- type Builder
- type Codec
- func (c *Codec) MarshalAccount(account Account) ([]byte, error)
- func (c *Codec) MarshalAccounts(accounts []Account) ([]byte, error)
- func (c *Codec) MarshalBlock(block *Block) ([]byte, error)
- func (c *Codec) MarshalGenesis(accounts []Account) ([]byte, error)
- func (c *Codec) MarshalTx(tx *Tx) ([]byte, error)
- func (c *Codec) MarshalUnsignedTx(tx *Tx) ([]byte, error)
- func (c *Codec) UnmarshalAccount(b []byte) (Account, error)
- func (c *Codec) UnmarshalAccounts(b []byte) ([]Account, error)
- func (c *Codec) UnmarshalBlock(b []byte) (*Block, error)
- func (c *Codec) UnmarshalGenesis(b []byte) ([]Account, error)
- func (c *Codec) UnmarshalTx(b []byte) (*Tx, error)
- type CodecID
- type Factory
- type GetAccountArgs
- type GetAccountReply
- type IssueTxArgs
- type IssueTxReply
- type Keychain
- func (kc *Keychain) Add(key *crypto.PrivateKeySECP256K1R)
- func (kc *Keychain) Addresses() ids.ShortSet
- func (kc *Keychain) Get(id ids.ShortID) (*crypto.PrivateKeySECP256K1R, bool)
- func (kc *Keychain) New() (*crypto.PrivateKeySECP256K1R, error)
- func (kc *Keychain) PrefixedString(prefix string) string
- func (kc *Keychain) Spend(account Account, amount uint64, destination ids.ShortID) (*Tx, Account, error)
- func (kc *Keychain) String() string
- type LiveBlock
- func (lb *LiveBlock) Accept()
- func (lb *LiveBlock) Bytes() []byte
- func (lb *LiveBlock) ID() ids.ID
- func (lb *LiveBlock) Parent() snowman.Block
- func (lb *LiveBlock) Reject()
- func (lb *LiveBlock) Status() choices.Status
- func (lb *LiveBlock) Verify() error
- func (lb *LiveBlock) VerifyBlock() error
- func (lb *LiveBlock) VerifyState() error
- type Service
- type StaticService
- type Tx
- type VM
- func (vm *VM) BuildBlock() (snowman.Block, error)
- func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler
- func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler
- func (vm *VM) FlushTxs()
- func (vm *VM) GetAccount(db database.Database, address ids.ShortID) Account
- func (vm *VM) GetBlock(id ids.ID) (snowman.Block, error)
- func (vm *VM) Initialize(ctx *snow.Context, db database.Database, genesisBytes []byte, ...) error
- func (vm *VM) IssueTx(b []byte, onDecide func(choices.Status)) (ids.ID, error)
- func (vm *VM) LastAccepted() ids.ID
- func (vm *VM) ParseBlock(b []byte) (snowman.Block, error)
- func (vm *VM) SetPreference(preferred ids.ID)
- func (vm *VM) Shutdown()
Constants ¶
This section is empty.
Variables ¶
var (
ID = ids.NewID([32]byte{'s', 'p', 'c', 'h', 'a', 'i', 'n', 'v', 'm'})
)
ID this VM should be referenced by
Functions ¶
This section is empty.
Types ¶
type APIAccount ¶
type APIAccount struct { Address ids.ShortID `json:"address"` Balance json.Uint64 `json:"balance"` }
APIAccount ...
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account represents the balance and nonce of a user's funds
func (Account) CreateTx ¶
func (a Account) CreateTx(amount uint64, destination ids.ShortID, ctx *snow.Context, key *crypto.PrivateKeySECP256K1R) (*Tx, Account, error)
CreateTx creates a transaction from this account that sends [amount] to the address [destination]
func (Account) VerifyReceive ¶
VerifyReceive returns if the provided transaction can receive this transaction
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is a group of transactions
type BuildGenesisArgs ¶
type BuildGenesisArgs struct {
Accounts []APIAccount `json:"accounts"`
}
BuildGenesisArgs are arguments for BuildGenesis
type BuildGenesisReply ¶
type BuildGenesisReply struct {
Bytes formatting.CB58 `json:"bytes"`
}
BuildGenesisReply is the reply from BuildGenesis
type Builder ¶
Builder defines the functionality for building payment objects.
func (Builder) NewAccount ¶
NewAccount creates a new Account
type Codec ¶
type Codec struct{}
Codec is used to serialize and de-serialize transaction objects
func (*Codec) MarshalAccount ¶
MarshalAccount returns the byte representation of the account
func (*Codec) MarshalAccounts ¶
MarshalAccounts returns the byte representation of a list of accounts
func (*Codec) MarshalBlock ¶
MarshalBlock returns the byte representation of the block
func (*Codec) MarshalGenesis ¶
MarshalGenesis returns the byte representation of the genesis
func (*Codec) MarshalUnsignedTx ¶
MarshalUnsignedTx returns the byte representation of the unsigned tx
func (*Codec) UnmarshalAccount ¶
UnmarshalAccount attempts to parse an account from a byte array
func (*Codec) UnmarshalAccounts ¶
UnmarshalAccounts attempts to parse a list of accounts from a byte array
func (*Codec) UnmarshalBlock ¶
UnmarshalBlock attempts to parse an block from a byte array
func (*Codec) UnmarshalGenesis ¶
UnmarshalGenesis attempts to parse the genesis
type GetAccountArgs ¶
GetAccountArgs is the arguments for calling GetAccount [Address] is the string repr. of the address we want to know the nonce and balance of
type GetAccountReply ¶
type GetAccountReply struct { Balance json.Uint64 `json:"balance"` Nonce json.Uint64 `json:"nonce"` }
GetAccountReply is the reply from calling GetAccount [nonce] is the nonce of the address specified in the arguments. [balance] is the balance of the address specified in the arguments.
type IssueTxArgs ¶
type IssueTxArgs struct {
Tx formatting.CB58 `json:"tx"`
}
IssueTxArgs are the arguments for IssueTx. Tx is the string representation of the transaction being issued
type IssueTxReply ¶
IssueTxReply is the reply from IssueTx [TxID] is the ID of the issued transaction.
type Keychain ¶
type Keychain struct { // Each element is an address controlled by a key in [Keys] // This can be used to iterate over. It should not be modified externally. Addrs ids.ShortSet // List of keys this keychain manages // This can be used to iterate over. It should not be modified externally. Keys []*crypto.PrivateKeySECP256K1R // contains filtered or unexported fields }
Keychain is a collection of keys that can be used to spend utxos
func NewKeychain ¶
NewKeychain creates a new keychain for a chain
func (*Keychain) Add ¶
func (kc *Keychain) Add(key *crypto.PrivateKeySECP256K1R)
Add a new key to the key chain
func (*Keychain) New ¶
func (kc *Keychain) New() (*crypto.PrivateKeySECP256K1R, error)
New returns a newly generated private key
func (*Keychain) PrefixedString ¶
PrefixedString returns a string representation of this keychain with each line prepended with [prefix]
type LiveBlock ¶
type LiveBlock struct {
// contains filtered or unexported fields
}
LiveBlock implements snow/snowman.Block
func (*LiveBlock) Accept ¶
func (lb *LiveBlock) Accept()
Accept is called when this block is finalized as accepted by consensus
func (*LiveBlock) Reject ¶
func (lb *LiveBlock) Reject()
Reject is called when this block is finalized as rejected by consensus
func (*LiveBlock) VerifyBlock ¶
VerifyBlock the validity of this block
func (*LiveBlock) VerifyState ¶
VerifyState the validity of this block
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service defines the API exposed by the payments vm
func (*Service) GetAccount ¶
func (service *Service) GetAccount(_ *http.Request, args *GetAccountArgs, reply *GetAccountReply) error
GetAccount gets the nonce and balance of the account specified in [args]
func (*Service) IssueTx ¶
func (service *Service) IssueTx(_ *http.Request, args *IssueTxArgs, reply *IssueTxReply) error
IssueTx issues the transaction specified in [args] to this service
type StaticService ¶
type StaticService struct{}
StaticService defines the static API exposed by the payments vm
func (*StaticService) BuildGenesis ¶
func (*StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, reply *BuildGenesisReply) error
BuildGenesis returns the UTXOs such that at least one address in [args.Addresses] is referenced in the UTXO.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a monetary transfer
func (*Tx) Key ¶
Key returns the public key used to authorize this transaction This function also sets [tx]'s public key
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM implements the snowman.ChainVM interface
func (*VM) BuildBlock ¶
BuildBlock implements the snowman.ChainVM interface
func (*VM) CreateHandlers ¶
func (vm *VM) CreateHandlers() map[string]*common.HTTPHandler
CreateHandlers makes new service objects with references to the vm
func (*VM) CreateStaticHandlers ¶
func (vm *VM) CreateStaticHandlers() map[string]*common.HTTPHandler
CreateStaticHandlers makes new service objects without references to the vm
func (*VM) GetAccount ¶
GetAccount returns the account with the specified address
func (*VM) Initialize ¶
func (vm *VM) Initialize( ctx *snow.Context, db database.Database, genesisBytes []byte, toEngine chan<- common.Message, fxs []*common.Fx, ) error
Initialize implements the snowman.ChainVM interface
func (*VM) LastAccepted ¶
LastAccepted returns the last accepted block ID
func (*VM) ParseBlock ¶
ParseBlock implements the snowman.ChainVM interface
func (*VM) SetPreference ¶
SetPreference sets what the current tail of the chain is