walletstore

package
v0.0.0-...-30b4a77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package walletstore implements a wallet storage

Index

Constants

This section is empty.

Variables

ExpireEdge is the time in which to renew an expiring token

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

func (*CacheData) Marshal

func (cd *CacheData) Marshal() string

Marshal a cachedata structure

func (*CacheData) Unmarshal

func (cd *CacheData) Unmarshal(d string) (*CacheData, error)

Unmarshal CacheData

type CacheDataDB

type CacheDataDB struct {
	AuthToken  []byte
	AuthTries  int
	VerifyKeys [][]byte
}

CacheDataDB contains a CacheData good for serialization

type Storage

type Storage struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

Storage implements an SQL-backed WalletStore interface

func New

func New(db interface{}) (*Storage, error)

New returns a new Storage, takes existing DB connection or URL as parameter

func NewFromDB

func NewFromDB(db *sql.DB) (*Storage, error)

NewFromDB returns a storage for an existing database connection

func NewFromURL

func NewFromURL(dburl string) (*Storage, error)

NewFromURL returns a Storage from a URL

func (*Storage) CleanLocks

func (ws *Storage) CleanLocks(force bool)

CleanLocks cleans all locks. If force is true all locks are removed, not only expired locks

func (*Storage) DelToken

func (ws *Storage) DelToken(tokenHash []byte)

DelToken deletes the token identified by tokenHash

func (*Storage) ExpireUnusable

func (ws *Storage) ExpireUnusable() bool

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

func (ws *Storage) GetAuthToken() (authToken []byte, tries int)

GetAuthToken gets authtoken from store

func (*Storage) GetBalance

func (ws *Storage) GetBalance(usage string, owner *[ed25519.PublicKeySize]byte) int64

GetBalance returns the number of usable tokens available for usage owned by owner or not self (if owner==nil)

func (*Storage) GetBalanceOwn

func (ws *Storage) GetBalanceOwn(usage string) int64

GetBalanceOwn returns the number of usable tokens available for usage that are owned by self

func (*Storage) GetExpire

func (ws *Storage) GetExpire() []byte

GetExpire returns the first expiring tokenHash or nil

func (*Storage) GetInReissue

func (ws *Storage) GetInReissue() []byte

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

func (ws *Storage) LockToken(tokenHash []byte) int64

LockToken locks token against other use. Return lockID > 0 on success, <0 on failure

func (*Storage) SetAuthToken

func (ws *Storage) SetAuthToken(authToken []byte, tries int) error

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

func (ws *Storage) UnlockToken(tokenHash []byte)

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

Directories

Path Synopsis
Package nilstore implements a walletstore without any abilities.
Package nilstore implements a walletstore without any abilities.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL