Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- func ChainAddr(addr sdk.Actor) sdk.Actor
- func ErrInsufficientCredit() errors.TMError
- func ErrInsufficientFunds() errors.TMError
- func ErrInvalidAddress() errors.TMError
- func ErrInvalidCoins() errors.TMError
- func ErrNoAccount() errors.TMError
- func ErrNoInputs() errors.TMError
- func ErrNoOutputs() errors.TMError
- func IsAddressErr(err error) bool
- func IsCoinErr(err error) bool
- func IsInputErr(err error) bool
- func IsInsufficientCreditErr(err error) bool
- func IsInsufficientFundsErr(err error) bool
- func IsInvalidAddressErr(err error) bool
- func IsInvalidCoinsErr(err error) bool
- func IsNoAccountErr(err error) bool
- func IsNoInputsErr(err error) bool
- func IsNoOutputsErr(err error) bool
- func IsOutputErr(err error) bool
- func NewCreditTx(debitor sdk.Actor, credit Coins) sdk.Tx
- func NewSendOneTx(sender, recipient sdk.Actor, amount Coins) sdk.Tx
- func NewSendTx(in []TxInput, out []TxOutput) sdk.Tx
- type Account
- type AccountWithKey
- type Coin
- type Coins
- func (coins Coins) IsEqual(coinsB Coins) bool
- func (coins Coins) IsGTE(coinsB Coins) bool
- func (coins Coins) IsNonnegative() bool
- func (coins Coins) IsPositive() bool
- func (coins Coins) IsValid() bool
- func (coins Coins) IsZero() bool
- func (coins Coins) Len() int
- func (coins Coins) Less(i, j int) bool
- func (coins Coins) Minus(coinsB Coins) Coins
- func (coins Coins) Negative() Coins
- func (coins Coins) Plus(coinsB Coins) Coins
- func (coins Coins) Sort()
- func (coins Coins) String() string
- func (coins Coins) Swap(i, j int)
- type CreditTx
- type GenesisAccount
- type Handler
- func (Handler) AssertDispatcher()
- func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error)
- func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, cb sdk.Deliver) (res sdk.DeliverResult, err error)
- func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, value string, ...) (log string, err error)
- func (Handler) Name() string
- type HandlerInfo
- type SendTx
- type TxInput
- type TxOutput
Constants ¶
const ( //NameCoin - name space of the coin module NameCoin = "coin" // CostSend is GasAllocation per input/output CostSend = uint64(10) // CostCredit is GasAllocation of a credit allocation CostCredit = uint64(20) )
const ( ByteSend = 0x20 TypeSend = NameCoin + "/send" ByteCredit = 0x21 TypeCredit = NameCoin + "/credit" )
we reserve the 0x20-0x3f range for standard modules
Variables ¶
This section is empty.
Functions ¶
func ChainAddr ¶
ChainAddr collapses all addresses from another chain into one, so we can keep an over-all balance
TODO: is there a better way to do this?
func ErrInsufficientCredit ¶
func ErrInsufficientFunds ¶
func ErrInvalidAddress ¶
func ErrInvalidCoins ¶
func ErrNoAccount ¶
func ErrNoInputs ¶
func ErrNoOutputs ¶
func IsAddressErr ¶
func IsInputErr ¶
here are some generic handlers to grab classes of errors based on code
func IsInsufficientCreditErr ¶
func IsInsufficientFundsErr ¶
func IsInvalidAddressErr ¶
func IsInvalidCoinsErr ¶
func IsNoAccountErr ¶
func IsNoInputsErr ¶
func IsNoOutputsErr ¶
func IsOutputErr ¶
func NewCreditTx ¶
NewCreditTx - modify the credit granted to a given account
func NewSendOneTx ¶
NewSendOneTx is a helper for the standard (?) case where there is exactly one sender and one recipient
Types ¶
type Account ¶
type Account struct { // Coins is how much is on the account Coins Coins `json:"coins"` // Credit is how much has been "fronted" to the account // (this is usually 0 except for trusted chains) Credit Coins `json:"credit"` }
Account - coin account structure
type AccountWithKey ¶
AccountWithKey is a helper for tests, that includes and account along with the private key to access it.
func NewAccountWithKey ¶
func NewAccountWithKey(coins Coins) *AccountWithKey
NewAccountWithKey creates an account with the given balance and a random private key
func (*AccountWithKey) Actor ¶
func (a *AccountWithKey) Actor() sdk.Actor
Actor returns the basecoin actor associated with this account
func (*AccountWithKey) Address ¶
func (a *AccountWithKey) Address() []byte
Address returns the public key address for this account
func (*AccountWithKey) MakeOption ¶
func (a *AccountWithKey) MakeOption() string
MakeOption returns a string to use with InitState to initialize this account
This is intended for use in test cases
func (*AccountWithKey) NextSequence ¶
func (a *AccountWithKey) NextSequence() uint32
NextSequence returns the next sequence to sign with
type Coin ¶
Coin hold some amount of one currency
func ParseCoin ¶
ParseCoin parses a cli input for one coin type, returning errors if invalid. This returns an error on an empty string as well.
type Coins ¶
type Coins []Coin
Coins is a set of Coin, one per currency
func ChangeCoins ¶
ChangeCoins changes the money, returns error if it would be negative
func CheckCoins ¶
CheckCoins makes sure there are funds, but doesn't change anything
func ParseCoins ¶
ParseCoins will parse out a list of coins separated by commas. If nothing is provided, it returns an empty array
func (Coins) IsGTE ¶
IsGTE returns True iff coins is NonNegative(), and for every currency in coinsB, the currency is present at an equal or greater amount in coinsB
func (Coins) IsNonnegative ¶
IsNonnegative returns true if there is no currency with a negative value (even no coins is true here)
func (Coins) IsPositive ¶
IsPositive returns true if there is at least one coin, and all currencies have a positive value
func (Coins) Plus ¶
Plus combines to sets of coins
TODO: handle empty coins! Currently appends an empty coin ...
type CreditTx ¶
type CreditTx struct { Debitor sdk.Actor `json:"debitor"` // Credit is the amount to change the credit... // This may be negative to remove some over-issued credit, // but can never bring the credit or the balance to negative Credit Coins `json:"credit"` }
CreditTx - this allows a special issuer to give an account credit Satisfies: TxInner
func (CreditTx) ValidateBasic ¶
ValidateBasic - used to satisfy TxInner
type GenesisAccount ¶
type GenesisAccount struct { Address data.Bytes `json:"address"` // this from types.Account (don't know how to embed this properly) PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known. Balance Coins `json:"coins"` }
GenesisAccount - genesis account parameters
func (GenesisAccount) GetAddr ¶
func (g GenesisAccount) GetAddr() ([]byte, error)
GetAddr - Get the address of the genesis account
func (GenesisAccount) ToAccount ¶
func (g GenesisAccount) ToAccount() Account
ToAccount - GenesisAccount struct to a basecoin Account
type Handler ¶
type Handler struct {
stack.PassInitValidate
}
Handler includes an accountant
func (Handler) AssertDispatcher ¶
func (Handler) AssertDispatcher()
AssertDispatcher - to fulfill Dispatchable interface
func (Handler) CheckTx ¶
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error)
CheckTx checks if there is enough money in the account
func (Handler) DeliverTx ¶
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, cb sdk.Deliver) (res sdk.DeliverResult, err error)
DeliverTx moves the money
type HandlerInfo ¶
HandlerInfo - this is global info on the coin handler
type SendTx ¶
SendTx - high level transaction of the coin module Satisfies: TxInner
func (SendTx) ValidateBasic ¶
ValidateBasic - validate the send transaction
type TxInput ¶
TxInput - expected coin movement outputs, used with SendTx
func NewTxInput ¶
NewTxInput - create a transaction input, used with SendTx
func (TxInput) ValidateBasic ¶
ValidateBasic - validate transaction input
type TxOutput ¶
TxOutput - expected coin movement output, used with SendTx
func NewTxOutput ¶
NewTxOutput - create a transaction output, used with SendTx
func (TxOutput) ValidateBasic ¶
ValidateBasic - validate transaction output