wallet

package module
v0.0.0-...-97c3377 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 29 Imported by: 0

README

Factom Wallet

This repo rehouses the core wallet code formerly located in the "FactomProject/factom/wallet" directory.

Documentation

Index

Constants

View Source
const (
	SeedLength = 64
	ApiVersion = "2.0"
)

Variables

View Source
var (
	ErrFeeTooLow         = errors.New("wallet: Insufficient Fee")
	ErrNoSuchAddress     = errors.New("wallet: No such address")
	ErrNoSuchIdentityKey = errors.New("wallet: No such identity key")
	ErrTXExists          = errors.New("wallet: Transaction name already exists")
	ErrTXNotExists       = errors.New("wallet: Transaction name was not found")
	ErrTXNoInputs        = errors.New("wallet: Transaction has no inputs")
	ErrTXInvalidName     = errors.New("wallet: Transaction name is not valid")
)
View Source
var APICounter = newCounter()
View Source
var WalletVersion string = "BuiltWithoutVersion"

Functions

func CreateEncryptedBoltDB

func CreateEncryptedBoltDB(boltPath string) error

func ExportEncryptedWallet

func ExportEncryptedWallet(path, password string) (string, []*factom.FactoidAddress, []*factom.ECAddress, error)

ExportEncryptedWallet writes all the secret/publilc key pairs from a wallet and the wallet seed in a pritable format.

func ExportLDBWallet

func ExportLDBWallet(path string) (string, []*factom.FactoidAddress, []*factom.ECAddress, error)

ExportLDBWallet writes all the secret/publilc key pairs from a wallet and the wallet seed in a pritable format.

func ExportWallet

func ExportWallet(path string) (string, []*factom.FactoidAddress, []*factom.ECAddress, error)

ExportWallet writes all the secret/publilc key pairs from a wallet and the wallet seed in a pritable format.

func SeedString

func SeedString(seed []byte) string

SeedString returnes the string representation of a raw Wallet Seed or Next Wallet Seed.

Types

type DBSeed

type DBSeed struct {
	DBSeedBase
}

func NewRandomSeed

func NewRandomSeed() (*DBSeed, error)

func (*DBSeed) JSONBuffer

func (e *DBSeed) JSONBuffer(b *bytes.Buffer) error

func (*DBSeed) JSONByte

func (e *DBSeed) JSONByte() ([]byte, error)

func (*DBSeed) JSONString

func (e *DBSeed) JSONString() (string, error)

func (*DBSeed) MarshalBinary

func (e *DBSeed) MarshalBinary() ([]byte, error)

func (*DBSeed) NextECAddress

func (e *DBSeed) NextECAddress() (*factom.ECAddress, error)

func (*DBSeed) NextFCTAddress

func (e *DBSeed) NextFCTAddress() (*factom.FactoidAddress, error)

func (*DBSeed) NextIdentityKey

func (e *DBSeed) NextIdentityKey() (*factom.IdentityKey, error)

func (*DBSeed) String

func (e *DBSeed) String() string

func (*DBSeed) UnmarshalBinary

func (e *DBSeed) UnmarshalBinary(data []byte) (err error)

func (*DBSeed) UnmarshalBinaryData

func (e *DBSeed) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type DBSeedBase

type DBSeedBase struct {
	MnemonicSeed            string
	NextFactoidAddressIndex uint32
	NextECAddressIndex      uint32
	NextIdentityKeyIndex    uint32
}

type ECA

type ECA struct {
	*factom.ECAddress
}

func (*ECA) New

type FA

type FA struct {
	*factom.FactoidAddress
}

func (*FA) New

type ID

type ID struct {
	*factom.IdentityKey
}

func (*ID) New

type TXDatabaseOverlay

type TXDatabaseOverlay struct {
	DBO databaseOverlay.Overlay
	// contains filtered or unexported fields
}

func NewTXBoltDB

func NewTXBoltDB(boltPath string) (*TXDatabaseOverlay, error)

func NewTXLevelDB

func NewTXLevelDB(ldbpath string) (*TXDatabaseOverlay, error)

func NewTXMapDB

func NewTXMapDB() *TXDatabaseOverlay

func NewTXOverlay

func NewTXOverlay(db interfaces.IDatabase) *TXDatabaseOverlay

func (*TXDatabaseOverlay) Close

func (db *TXDatabaseOverlay) Close() error

func (*TXDatabaseOverlay) FetchNextFBlockHeight

func (db *TXDatabaseOverlay) FetchNextFBlockHeight() (uint32, error)

func (*TXDatabaseOverlay) GetAllTXs

func (db *TXDatabaseOverlay) GetAllTXs() ([]interfaces.ITransaction, error)

GetAllTXs returns a list of all transactions in the history of Factom. A local database is used to cache the factoid blocks.

func (*TXDatabaseOverlay) GetFBlock

func (db *TXDatabaseOverlay) GetFBlock(keymr string) (interfaces.IFBlock, error)

GetFBlock retrives a Factoid Block from Factom

func (*TXDatabaseOverlay) GetTX

GetTX gets a transaction by the transaction id

func (*TXDatabaseOverlay) GetTXAddress

func (db *TXDatabaseOverlay) GetTXAddress(adr string) (
	[]interfaces.ITransaction, error)

GetTXAddress returns a list of all transactions in the history of Factom that include a specific address.

func (*TXDatabaseOverlay) GetTXRange

func (db *TXDatabaseOverlay) GetTXRange(start, end int) (
	[]interfaces.ITransaction, error)

func (*TXDatabaseOverlay) InsertFBlockHead

func (db *TXDatabaseOverlay) InsertFBlockHead(fblock interfaces.IFBlock) error

func (*TXDatabaseOverlay) Update

func (db *TXDatabaseOverlay) Update() (string, error)

Update gets all fblocks written since the database was last updated, and returns the most recent fblock keymr.

type Wallet

type Wallet struct {
	*WalletDatabaseOverlay
	Encrypted bool
	DBPath    string
	// contains filtered or unexported fields
}

Wallet is a connection to a Factom Wallet Database

func ImportEncryptedWalletFromMnemonic

func ImportEncryptedWalletFromMnemonic(mnemonic, path, password string) (*Wallet, error)

ImportEncryptedWalletFromMnemonic creates a new wallet with a provided Mnemonic seed defined in bip-0039.

func ImportLDBWalletFromMnemonic

func ImportLDBWalletFromMnemonic(mnemonic, path string) (*Wallet, error)

ImportWalletFromMnemonic creates a new wallet with a provided Mnemonic seed defined in bip-0039.

func ImportV1Wallet

func ImportV1Wallet(v1path, v2path string) (*Wallet, error)

ImportV1Wallet takes a version 1 wallet bolt.db file and imports all of its addresses into a factom wallet.

func ImportV1WalletToEncryptedDB

func ImportV1WalletToEncryptedDB(v1path, v2path, password string) (*Wallet, error)

ImportV1WalletToEncryptedDB takes a version 1 wallet bolt.db file and imports all of its addresses into a factom wallet.

func ImportV1WalletToLDB

func ImportV1WalletToLDB(v1path, v2path string) (*Wallet, error)

ImportV1WalletToLDB takes a version 1 wallet bolt.db file and imports all of its addresses into a factom wallet.

func ImportWalletFromMnemonic

func ImportWalletFromMnemonic(mnemonic, path string) (*Wallet, error)

ImportWalletFromMnemonic creates a new wallet with a provided Mnemonic seed defined in bip-0039.

func NewEncryptedBoltDBWallet

func NewEncryptedBoltDBWallet(path, password string) (*Wallet, error)

func NewEncryptedBoltDBWalletAwaitingPassphrase

func NewEncryptedBoltDBWalletAwaitingPassphrase(path string) (*Wallet, error)

func NewMapDBWallet

func NewMapDBWallet() (*Wallet, error)

func NewOrOpenBoltDBWallet

func NewOrOpenBoltDBWallet(path string) (*Wallet, error)

func NewOrOpenLevelDBWallet

func NewOrOpenLevelDBWallet(path string) (*Wallet, error)

func (*Wallet) AddECOutput

func (w *Wallet) AddECOutput(name, address string, amount uint64) error

func (*Wallet) AddFee

func (w *Wallet) AddFee(name, address string, rate uint64) error

func (*Wallet) AddInput

func (w *Wallet) AddInput(name, address string, amount uint64) error

func (*Wallet) AddOutput

func (w *Wallet) AddOutput(name, address string, amount uint64) error

func (*Wallet) AddTXDB

func (w *Wallet) AddTXDB(t *TXDatabaseOverlay)

AddTXDB allows the wallet api to read from a local transaction cashe.

func (*Wallet) Close

func (w *Wallet) Close() error

Close closes a Factom Wallet Database

func (*Wallet) ComposeTransaction

func (w *Wallet) ComposeTransaction(name string) (*factom.JSON2Request, error)

func (*Wallet) DeleteTransaction

func (w *Wallet) DeleteTransaction(name string) error

func (*Wallet) GenerateECAddress

func (w *Wallet) GenerateECAddress() (*factom.ECAddress, error)

GenerateECAddress creates and stores a new Entry Credit Address in the Wallet. The address can be reproduced in the future using the Wallet Seed.

func (*Wallet) GenerateFCTAddress

func (w *Wallet) GenerateFCTAddress() (*factom.FactoidAddress, error)

GenerateFCTAddress creates and stores a new Factoid Address in the Wallet. The address can be reproduced in the future using the Wallet Seed.

func (*Wallet) GenerateIdentityKey

func (w *Wallet) GenerateIdentityKey() (*factom.IdentityKey, error)

GenerateIdentityKey creates and stores a new Identity Key in the Wallet.

func (*Wallet) GetAllAddresses

func (w *Wallet) GetAllAddresses() ([]*factom.FactoidAddress, []*factom.ECAddress, error)

GetAllAddresses retrieves all Entry Credit and Factoid Addresses from the Wallet Database.

func (*Wallet) GetApiVersion

func (w *Wallet) GetApiVersion() string

func (*Wallet) GetSeed

func (w *Wallet) GetSeed() (string, error)

GetSeed returns the string representaion of the Wallet Seed. The Wallet Seed can be used to regenerate the Factoid and Entry Credit Addresses previously generated by the wallet. Note that Addresses that are imported into the Wallet cannot be regenerated using the Wallet Seed.

func (*Wallet) GetTransaction

func (w *Wallet) GetTransaction(name string) (*factoid.Transaction, error)

func (*Wallet) GetTransactions

func (w *Wallet) GetTransactions() map[string]*factoid.Transaction

func (*Wallet) GetVersion

func (w *Wallet) GetVersion() string

func (*Wallet) ImportComposedTransaction

func (w *Wallet) ImportComposedTransaction(name string, hexEncoded string) error

Hexencoded transaction

func (*Wallet) InitWallet

func (w *Wallet) InitWallet() error

func (*Wallet) NewTransaction

func (w *Wallet) NewTransaction(name string) error

func (*Wallet) SignData

func (w *Wallet) SignData(signer string, data []byte) ([]byte, []byte, error)

SignData signs arbitrary data

func (*Wallet) SignTransaction

func (w *Wallet) SignTransaction(name string, force bool) error

SignTransaction signs a tmp transaction in the wallet with the appropriate keys from the wallet db force=true ignores the existing balance and fee overpayment checks.

func (*Wallet) SubFee

func (w *Wallet) SubFee(name, address string, rate uint64) error

func (*Wallet) TXDB

func (w *Wallet) TXDB() *TXDatabaseOverlay

TXDB returns a handle for the Transaction Database.

func (*Wallet) TransactionExists

func (w *Wallet) TransactionExists(name string) bool

type WalletDatabaseOverlay

type WalletDatabaseOverlay struct {
	DBO databaseOverlay.Overlay
}

func NewBoltDB

func NewBoltDB(boltPath string) (*WalletDatabaseOverlay, error)

func NewEncryptedBoltDB

func NewEncryptedBoltDB(boltPath, password string) (*WalletDatabaseOverlay, error)

func NewLevelDB

func NewLevelDB(ldbpath string) (*WalletDatabaseOverlay, error)

func NewMapDB

func NewMapDB() *WalletDatabaseOverlay

func OpenEncryptedBoltDB

func OpenEncryptedBoltDB(boltPath, password string) (*WalletDatabaseOverlay, error)

func (*WalletDatabaseOverlay) GetAllECAddresses

func (db *WalletDatabaseOverlay) GetAllECAddresses() ([]*factom.ECAddress, error)

func (*WalletDatabaseOverlay) GetAllFCTAddresses

func (db *WalletDatabaseOverlay) GetAllFCTAddresses() ([]*factom.FactoidAddress, error)

func (*WalletDatabaseOverlay) GetAllIdentityKeys

func (db *WalletDatabaseOverlay) GetAllIdentityKeys() ([]*factom.IdentityKey, error)

func (*WalletDatabaseOverlay) GetDBSeed

func (db *WalletDatabaseOverlay) GetDBSeed() (*DBSeed, error)

func (*WalletDatabaseOverlay) GetECAddress

func (db *WalletDatabaseOverlay) GetECAddress(pubString string) (*factom.ECAddress, error)

func (*WalletDatabaseOverlay) GetFCTAddress

func (db *WalletDatabaseOverlay) GetFCTAddress(str string) (*factom.FactoidAddress, error)

func (*WalletDatabaseOverlay) GetIdentityKey

func (db *WalletDatabaseOverlay) GetIdentityKey(str string) (*factom.IdentityKey, error)

func (*WalletDatabaseOverlay) GetNextECAddress

func (db *WalletDatabaseOverlay) GetNextECAddress() (*factom.ECAddress, error)

func (*WalletDatabaseOverlay) GetNextFCTAddress

func (db *WalletDatabaseOverlay) GetNextFCTAddress() (*factom.FactoidAddress, error)

func (*WalletDatabaseOverlay) GetNextIdentityKey

func (db *WalletDatabaseOverlay) GetNextIdentityKey() (*factom.IdentityKey, error)

func (*WalletDatabaseOverlay) GetOrCreateDBSeed

func (db *WalletDatabaseOverlay) GetOrCreateDBSeed() (*DBSeed, error)

func (*WalletDatabaseOverlay) InsertDBSeed

func (db *WalletDatabaseOverlay) InsertDBSeed(seed *DBSeed) error

func (*WalletDatabaseOverlay) InsertECAddress

func (db *WalletDatabaseOverlay) InsertECAddress(e *factom.ECAddress) error

func (*WalletDatabaseOverlay) InsertFCTAddress

func (db *WalletDatabaseOverlay) InsertFCTAddress(e *factom.FactoidAddress) error

func (*WalletDatabaseOverlay) InsertIdentityKey

func (db *WalletDatabaseOverlay) InsertIdentityKey(e *factom.IdentityKey) error

func (*WalletDatabaseOverlay) RemoveAddress

func (db *WalletDatabaseOverlay) RemoveAddress(pubString string) error

func (*WalletDatabaseOverlay) RemoveIdentityKey

func (db *WalletDatabaseOverlay) RemoveIdentityKey(pubString string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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