Documentation ¶
Overview ¶
Package walletstore implements a wallet storage
Index ¶
- Variables
- type CacheData
- type CacheDataDB
- type Storage
- func (ws *Storage) CleanLocks(force bool)
- func (ws *Storage) DelToken(tokenHash []byte)
- func (ws *Storage) ExpireUnusable() bool
- func (ws *Storage) FindToken(usage string) (*client.TokenEntry, error)
- func (ws *Storage) GetAndLockToken(usage string, owner *[ed25519.PublicKeySize]byte) (*client.TokenEntry, error)
- func (ws *Storage) GetAuthToken() (authToken []byte, tries int)
- func (ws *Storage) GetBalance(usage string, owner *[ed25519.PublicKeySize]byte) int64
- func (ws *Storage) GetBalanceOwn(usage string) int64
- func (ws *Storage) GetExpire() []byte
- func (ws *Storage) GetInReissue() []byte
- func (ws *Storage) GetToken(tokenHash []byte, lockID int64) (tokenEntry *client.TokenEntry, err error)
- func (ws *Storage) GetVerifyKeys() [][ed25519.PublicKeySize]byte
- func (ws *Storage) LockToken(tokenHash []byte) int64
- func (ws *Storage) SetAuthToken(authToken []byte, tries int) error
- func (ws *Storage) SetToken(tokenEntry client.TokenEntry) error
- func (ws *Storage) SetVerifyKeys(verifyKeys [][ed25519.PublicKeySize]byte)
- func (ws *Storage) UnlockToken(tokenHash []byte)
- type TokenEntryDBGlobal
- type TokenEntryDBState
Constants ¶
This section is empty.
Variables ¶
var ExpireEdge = constants.ClientExpireEdge
ExpireEdge is the time in which to renew an expiring token
var MaxLockAge = constants.ClientMaxLockAge
MaxLockAge is the maximum time a lock may persist
Functions ¶
This section is empty.
Types ¶
type CacheData ¶
type CacheData struct { AuthToken []byte AuthTries int VerifyKeys [][ed25519.PublicKeySize]byte }
CacheData contains cached data for the wallet process
type CacheDataDB ¶
CacheDataDB contains a CacheData good for serialization
type Storage ¶
Storage implements an SQL-backed WalletStore interface
func NewFromURL ¶
NewFromURL returns a Storage from a URL
func (*Storage) CleanLocks ¶
CleanLocks cleans all locks. If force is true all locks are removed, not only expired locks
func (*Storage) ExpireUnusable ¶
ExpireUnusable expires all tokens that cannot be used anymore (expired). Returns bool if it should be called again since it only expires 10 tokens at a time
func (*Storage) FindToken ¶
func (ws *Storage) FindToken(usage string) (*client.TokenEntry, error)
FindToken finds a token owned by self that has usage set
func (*Storage) GetAndLockToken ¶
func (ws *Storage) GetAndLockToken(usage string, owner *[ed25519.PublicKeySize]byte) (*client.TokenEntry, error)
GetAndLockToken returns a token matching usage and optional owner. Must return ErrNoToken if no token is in store
func (*Storage) GetAuthToken ¶
GetAuthToken gets authtoken from store
func (*Storage) GetBalance ¶
GetBalance returns the number of usable tokens available for usage owned by owner or not self (if owner==nil)
func (*Storage) GetBalanceOwn ¶
GetBalanceOwn returns the number of usable tokens available for usage that are owned by self
func (*Storage) GetInReissue ¶
GetInReissue returns the first token that has an active reissue that is not finished
func (*Storage) GetToken ¶
func (ws *Storage) GetToken(tokenHash []byte, lockID int64) (tokenEntry *client.TokenEntry, err error)
GetToken returns the token identified by tokenHash. If lockID>=0, enforce lock (return ErrLocked)
func (*Storage) GetVerifyKeys ¶
func (ws *Storage) GetVerifyKeys() [][ed25519.PublicKeySize]byte
GetVerifyKeys loads verification keys
func (*Storage) LockToken ¶
LockToken locks token against other use. Return lockID > 0 on success, <0 on failure
func (*Storage) SetAuthToken ¶
SetAuthToken stores an authtoken and tries
func (*Storage) SetToken ¶
func (ws *Storage) SetToken(tokenEntry client.TokenEntry) error
SetToken writes a token to the walletstore. repeated calls update the entry of tokenEntry.Hash is the same
func (*Storage) SetVerifyKeys ¶
func (ws *Storage) SetVerifyKeys(verifyKeys [][ed25519.PublicKeySize]byte)
SetVerifyKeys saves verification keys
func (*Storage) UnlockToken ¶
UnlockToken unlocks a locked token
type TokenEntryDBGlobal ¶
type TokenEntryDBGlobal struct { Hash string // The unique token identifier Token string // The token itself, marshalled OwnerPubKey string // The Owner of the token OwnerPrivKey string // The private key of the owner, can be nil if specified for somebody else Renewable bool // The token can be renewed (at least once) CanReissue bool // Can this token be reissued? Usage string // Usage of the token Expire int64 // When the token will expire OwnedSelf bool // Is token owned by myself HasParams bool // Are params available for the token HasState bool // Is state present? }
TokenEntryDBGlobal is the global table for tokens
type TokenEntryDBState ¶
type TokenEntryDBState struct { Params []byte // Params for the token, can be nil ServerPacket []byte // Packet to be send to server BlindingFactors []byte // Local blinding factors NewOwnerPubKey []byte // The Owner of the token after reissue NewOwnerPrivKey []byte // The private key of the new owner, can be nil if specified for somebody else }
TokenEntryDBState contains processing state and params for a token