Documentation ¶
Overview ¶
Package namecoin is a generated protocol buffer package. It is generated from these files: x/namecoin/codec.proto It has these top-level messages: Wallet Token NewTokenMsg SetWalletNameMsg
package namecoin is an extension of x/cash from weave, allowing more information for wallets and tokens.
Token tickers (currency code) must be registered before they can be used, and are associated with a human readable name, as well as a flexible number of significant figures.
Wallets also have a name associated with them, which must be unique and can be used to locate the wallet (secondary index).
Index ¶
- Constants
- Variables
- func AsTicker(obj orm.Object) string
- func BuildGenesis(wallets []GenesisAccount, tokens []GenesisToken) (weave.Options, error)
- func ErrChangeWalletName() error
- func ErrDuplicateToken(name string) error
- func ErrInvalidIndex(reason string) error
- func ErrInvalidSigFigs(figs int32) error
- func ErrInvalidTokenName(name string) error
- func ErrInvalidWalletName(name string) error
- func ErrNoSuchWallet(addr []byte) error
- func IsInvalidIndex(err error) bool
- func IsInvalidToken(err error) bool
- func IsInvalidWallet(err error) bool
- func NewController() cash.Controller
- func NewFeeDecorator(auth x.Authenticator, min x.Coin) weave.Decorator
- func NewSendHandler(auth x.Authenticator) weave.Handler
- func NewSetNameHandler(auth x.Authenticator, bucket NamedBucket) weave.Handler
- func NewToken(ticker, name string, sigFigs int32) orm.Object
- func NewTokenHandler(auth x.Authenticator, issuer weave.Address) weave.Handler
- func NewWallet(key weave.Address) orm.Object
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator, issuer weave.Address)
- func WalletWith(key weave.Address, name string, coins ...*x.Coin) (orm.Object, error)
- type GenesisAccount
- type GenesisToken
- type Initializer
- type Named
- type NamedBucket
- type NewTokenMsg
- func (*NewTokenMsg) Descriptor() ([]byte, []int)
- func (m *NewTokenMsg) GetName() string
- func (m *NewTokenMsg) GetSigFigs() int32
- func (m *NewTokenMsg) GetTicker() string
- func (m *NewTokenMsg) Marshal() (dAtA []byte, err error)
- func (m *NewTokenMsg) MarshalTo(dAtA []byte) (int, error)
- func (NewTokenMsg) Path() string
- func (*NewTokenMsg) ProtoMessage()
- func (m *NewTokenMsg) Reset()
- func (m *NewTokenMsg) Size() (n int)
- func (m *NewTokenMsg) String() string
- func (m *NewTokenMsg) Unmarshal(dAtA []byte) error
- func (t *NewTokenMsg) Validate() error
- type SetNameHandler
- type SetWalletNameMsg
- func (*SetWalletNameMsg) Descriptor() ([]byte, []int)
- func (m *SetWalletNameMsg) GetAddress() []byte
- func (m *SetWalletNameMsg) GetName() string
- func (m *SetWalletNameMsg) Marshal() (dAtA []byte, err error)
- func (m *SetWalletNameMsg) MarshalTo(dAtA []byte) (int, error)
- func (SetWalletNameMsg) Path() string
- func (*SetWalletNameMsg) ProtoMessage()
- func (m *SetWalletNameMsg) Reset()
- func (m *SetWalletNameMsg) Size() (n int)
- func (m *SetWalletNameMsg) String() string
- func (m *SetWalletNameMsg) Unmarshal(dAtA []byte) error
- func (s *SetWalletNameMsg) Validate() error
- type TickerBucket
- type Token
- func (t *Token) Copy() orm.CloneableData
- func (*Token) Descriptor() ([]byte, []int)
- func (m *Token) GetName() string
- func (m *Token) GetSigFigs() int32
- func (m *Token) Marshal() (dAtA []byte, err error)
- func (m *Token) MarshalTo(dAtA []byte) (int, error)
- func (*Token) ProtoMessage()
- func (m *Token) Reset()
- func (m *Token) Size() (n int)
- func (m *Token) String() string
- func (m *Token) Unmarshal(dAtA []byte) error
- func (t *Token) Validate() error
- type TokenBucket
- type TokenHandler
- type Wallet
- func (w *Wallet) Copy() orm.CloneableData
- func (*Wallet) Descriptor() ([]byte, []int)
- func (m *Wallet) GetCoins() []*x.Coin
- func (m *Wallet) GetName() string
- func (m *Wallet) Marshal() (dAtA []byte, err error)
- func (m *Wallet) MarshalTo(dAtA []byte) (int, error)
- func (*Wallet) ProtoMessage()
- func (m *Wallet) Reset()
- func (w *Wallet) SetCoins(coins []*x.Coin)
- func (w *Wallet) SetName(name string) error
- func (m *Wallet) Size() (n int)
- func (m *Wallet) String() string
- func (m *Wallet) Unmarshal(dAtA []byte) error
- func (w *Wallet) Validate() error
- type WalletBucket
Constants ¶
const ( CodeInvalidToken = 1000 CodeInvalidIndex = 1001 CodeInvalidWallet = 1002 )
ABCI Response Codes bov takes 1000-1100 namecoin takes 1000-1010
const ( // BucketNameToken is where we store the token definitions BucketNameToken = "tkn" // DefaultSigFigs is the default for any new token DefaultSigFigs = 9 )
const ( // BucketNameWallet is where we store the balances BucketNameWallet = "wllt" // IndexName is the index to query wallet by name IndexName = "name" )
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
var ( // IsTokenName limits the human-readable names of the tokens, // subset of ASCII to avoid unicode tricks. IsTokenName = regexp.MustCompile(`^[A-Za-z0-9 \-_:]{3,32}$`).MatchString // IsWalletName is allowed names to attach to a wallet address IsWalletName = regexp.MustCompile(`^[a-z0-9_]{4,20}$`).MatchString )
Functions ¶
func BuildGenesis ¶
func BuildGenesis(wallets []GenesisAccount, tokens []GenesisToken) (weave.Options, error)
BuildGenesis will create Options with the given the wallets and tokens
func ErrChangeWalletName ¶
func ErrChangeWalletName() error
func ErrDuplicateToken ¶
func ErrInvalidIndex ¶
func ErrInvalidSigFigs ¶
func ErrInvalidTokenName ¶
func ErrInvalidWalletName ¶
func ErrNoSuchWallet ¶
func IsInvalidIndex ¶
func IsInvalidToken ¶
func IsInvalidWallet ¶
func NewController ¶
func NewController() cash.Controller
NewController uses the default implementation for now.
TODO: better enforce token presence and sigfigs
func NewFeeDecorator ¶
NewFeeDecorator customizes cash/FeeDecorator to use our WalletBucket
func NewSendHandler ¶
func NewSendHandler(auth x.Authenticator) weave.Handler
NewSendHandler customizes cash/SendHandler to use our WalletBucket
func NewSetNameHandler ¶
func NewSetNameHandler(auth x.Authenticator, bucket NamedBucket) weave.Handler
NewSetNameHandler creates a handler that lets you set the name on a wallet one time.
func NewTokenHandler ¶
NewTokenHandler creates a handler that allows issuer to create new token types. If issuer is nil, anyone can create new tokens. TODO: check that permissioning???
func NewWallet ¶
NewWallet creates an empty wallet with this address serves as an object for the bucket
func RegisterQuery ¶
func RegisterQuery(qr weave.QueryRouter)
RegisterQuery will register wallets as "/wallets" and tokens as "/tokens"
func RegisterRoutes ¶
RegisterRoutes will instantiate and register all handlers in this package
Types ¶
type GenesisAccount ¶
GenesisAccount is used to parse the json from genesis file use weave.Address, so address in hex, not base64
type GenesisToken ¶
type GenesisToken struct { Ticker string `json:"ticker"` Name string `json:"name"` SigFigs int32 `json:"sig_figs"` }
GenesisToken is used to describe a token in the genesis account
func ToGenesisToken ¶
func ToGenesisToken(ticker string, token *Token) GenesisToken
ToGenesisToken converts internal structs to genesis file format
type Initializer ¶
type Initializer struct{}
Initializer fulfils the InitStater interface to load data from the genesis file
func (Initializer) FromGenesis ¶
FromGenesis will parse initial account info from genesis and save it to the database
type Named ¶
Named is any object that allows getting/setting a string name the object should be able to validate if SetName is a valid
type NamedBucket ¶
type NamedBucket interface { GetOrCreate(db weave.KVStore, key weave.Address) (orm.Object, error) Get(db weave.ReadOnlyKVStore, key []byte) (orm.Object, error) GetByName(db weave.KVStore, name string) (orm.Object, error) Save(db weave.KVStore, obj orm.Object) error }
NamedBucket is a bucket that can handle object with Get/SetName The object it returns must support AsNamed (only checked runtime :()
type NewTokenMsg ¶
type NewTokenMsg struct { Ticker string `protobuf:"bytes,1,opt,name=ticker,proto3" json:"ticker,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` SigFigs int32 `protobuf:"varint,3,opt,name=sig_figs,json=sigFigs,proto3" json:"sig_figs,omitempty"` }
NewTokenMsg will register a new token. This must not conflict with any existing ticker, and should be limited to privledged users.
func BuildTokenMsg ¶
func BuildTokenMsg(ticker, name string, sigFigs int32) *NewTokenMsg
BuildTokenMsg is a compact constructor for *NewTokenMsg
func (*NewTokenMsg) Descriptor ¶
func (*NewTokenMsg) Descriptor() ([]byte, []int)
func (*NewTokenMsg) GetName ¶
func (m *NewTokenMsg) GetName() string
func (*NewTokenMsg) GetSigFigs ¶
func (m *NewTokenMsg) GetSigFigs() int32
func (*NewTokenMsg) GetTicker ¶
func (m *NewTokenMsg) GetTicker() string
func (*NewTokenMsg) Marshal ¶
func (m *NewTokenMsg) Marshal() (dAtA []byte, err error)
func (NewTokenMsg) Path ¶
func (NewTokenMsg) Path() string
Path returns the routing path for this message
func (*NewTokenMsg) ProtoMessage ¶
func (*NewTokenMsg) ProtoMessage()
func (*NewTokenMsg) Reset ¶
func (m *NewTokenMsg) Reset()
func (*NewTokenMsg) Size ¶
func (m *NewTokenMsg) Size() (n int)
func (*NewTokenMsg) String ¶
func (m *NewTokenMsg) String() string
func (*NewTokenMsg) Unmarshal ¶
func (m *NewTokenMsg) Unmarshal(dAtA []byte) error
func (*NewTokenMsg) Validate ¶
func (t *NewTokenMsg) Validate() error
Validate makes sure that this is sensible
type SetNameHandler ¶
type SetNameHandler struct {
// contains filtered or unexported fields
}
SetNameHandler will set a name for objects in this bucket
type SetWalletNameMsg ¶
type SetWalletNameMsg struct { Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` }
SetWalletNameMsg will set the name on an existing wallet. Can only be performed if the wallet name is empty.
func BuildSetNameMsg ¶
func BuildSetNameMsg(addr weave.Address, name string) *SetWalletNameMsg
BuildSetNameMsg is a compact constructor for *SetWalletNameMsg
func (*SetWalletNameMsg) Descriptor ¶
func (*SetWalletNameMsg) Descriptor() ([]byte, []int)
func (*SetWalletNameMsg) GetAddress ¶
func (m *SetWalletNameMsg) GetAddress() []byte
func (*SetWalletNameMsg) GetName ¶
func (m *SetWalletNameMsg) GetName() string
func (*SetWalletNameMsg) Marshal ¶
func (m *SetWalletNameMsg) Marshal() (dAtA []byte, err error)
func (SetWalletNameMsg) Path ¶
func (SetWalletNameMsg) Path() string
Path returns the routing path for this message
func (*SetWalletNameMsg) ProtoMessage ¶
func (*SetWalletNameMsg) ProtoMessage()
func (*SetWalletNameMsg) Reset ¶
func (m *SetWalletNameMsg) Reset()
func (*SetWalletNameMsg) Size ¶
func (m *SetWalletNameMsg) Size() (n int)
func (*SetWalletNameMsg) String ¶
func (m *SetWalletNameMsg) String() string
func (*SetWalletNameMsg) Unmarshal ¶
func (m *SetWalletNameMsg) Unmarshal(dAtA []byte) error
func (*SetWalletNameMsg) Validate ¶
func (s *SetWalletNameMsg) Validate() error
Validate makes sure that this is sensible
type TickerBucket ¶
type TickerBucket interface { // GetOrCreate(db weave.KVStore, ticker string) (orm.Object, error) Get(db weave.KVStore, ticker string) (orm.Object, error) Save(db weave.KVStore, obj orm.Object) error }
TickerBucket can save and query Tokens (or anything with tickers...)
type Token ¶
type Token struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` SigFigs int32 `protobuf:"varint,3,opt,name=sig_figs,json=sigFigs,proto3" json:"sig_figs,omitempty"` }
Token contains information about a registered currency
func (*Token) Copy ¶
func (t *Token) Copy() orm.CloneableData
Copy makes a new set with the same coins
func (*Token) Descriptor ¶
func (*Token) GetSigFigs ¶
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
type TokenBucket ¶
TokenBucket is a type-safe wrapper around orm.Bucket
func NewTokenBucket ¶
func NewTokenBucket() TokenBucket
NewTokenBucket initializes a TokenBucket with default name
type TokenHandler ¶
type TokenHandler struct {
// contains filtered or unexported fields
}
TokenHandler will handle creating new tokens
type Wallet ¶
type Wallet struct { Coins []*x.Coin `protobuf:"bytes,1,rep,name=coins" json:"coins,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` }
Wallet has a name and a set of coins
func (*Wallet) Copy ¶
func (w *Wallet) Copy() orm.CloneableData
Copy makes a new set with the same coins
func (*Wallet) Descriptor ¶
func (*Wallet) ProtoMessage ¶
func (*Wallet) ProtoMessage()
func (*Wallet) SetCoins ¶
SetCoins lets us modify the wallet and satisfy Coinage to be compatible with x/cash
type WalletBucket ¶
WalletBucket is a type-safe wrapper around orm.Bucket
func NewWalletBucket ¶
func NewWalletBucket() WalletBucket
NewWalletBucket initializes a WalletBucket and sets up a unique index by name
func (WalletBucket) GetByName ¶
GetByName queries the wallet by secondary index on name, may return nil or a matching wallet
func (WalletBucket) GetOrCreate ¶
GetOrCreate will return the token if found, or create one with the given name otherwise.