wallet

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: ISC Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountMixerConfigSet      = "account_mixer_config_set"
	AccountMixerMixedAccount   = "account_mixer_mixed_account"
	AccountMixerUnmixedAccount = "account_mixer_unmixed_account"
	AccountMixerMixTxChange    = "account_mixer_mix_tx_change"

	LogLevelConfigKey           = "log_level"
	PrivacyModeConfigKey        = "privacy_mode"
	SpendUnconfirmedConfigKey   = "spend_unconfirmed"
	CurrencyConversionConfigKey = "currency_conversion_option"

	IsStartupSecuritySetConfigKey = "startup_security_set"
	StartupSecurityTypeConfigKey  = "startup_security_type"
	UseBiometricConfigKey         = "use_biometric"

	IncomingTxNotificationsConfigKey = "tx_notification_enabled"
	BeepNewBlocksConfigKey           = "beep_new_blocks"

	SyncOnCellularConfigKey             = "always_sync"
	NetworkModeConfigKey                = "network_mode"
	SpvPersistentPeerAddressesConfigKey = "spv_peer_addresses"
	UserAgentConfigKey                  = "user_agent"

	PoliteiaNotificationConfigKey = "politeia_notification"

	LastTxHashConfigKey = "last_tx_hash"

	KnownVSPsConfigKey = "known_vsps"

	TicketBuyerVSPHostConfigKey = "tb_vsp_host"
	TicketBuyerWalletConfigKey  = "tb_wallet_id"
	TicketBuyerAccountConfigKey = "tb_account_number"
	TicketBuyerATMConfigKey     = "tb_amount_to_maintain"

	ExchangeSourceDstnTypeConfigKey = "exchange_source_destination_key"

	HideBalanceConfigKey             = "hide_balance"
	AutoSyncConfigKey                = "autoSync"
	FetchProposalConfigKey           = "fetch_proposals"
	SeedBackupNotificationConfigKey  = "seed_backup_notification"
	ProposalNotificationConfigKey    = "proposal_notification_key"
	TransactionNotificationConfigKey = "transaction_notification_key"
	SpendUnmixedFundsKey             = "spend_unmixed_funds"
	KnownDexServersConfigKey         = "known_dex_servers"
	LanguagePreferenceKey            = "app_language"
	DarkModeConfigKey                = "dark_mode"
	HideTotalBalanceConfigKey        = "hideTotalUSDBalance"
	IsCEXFirstVisitConfigKey         = "is_cex_first_visit"

	PassphraseTypePin  int32 = 0
	PassphraseTypePass int32 = 1
)
View Source
const (

	// UnminedTxHeight defines the block height of the txs in the mempool
	UnminedTxHeight int32 = -1
)

Variables

View Source
var InvalidBlock = &BlockInfo{
	Height:    -1,
	Timestamp: -1,
}

InvalidBlock defines invalid height and timestamp returned in case of an error.

Functions

func Balances added in v1.1.0

func Balances(w Asset) (AssetAmount, AssetAmount, error)

Balances returns the spendable balance and total balance of the wallet.

func DecodeSeedMnemonic

func DecodeSeedMnemonic(seedMnemonic string, assetType utils.AssetType) (hashedSeed []byte, err error)

func ParseWalletPeers added in v1.1.0

func ParseWalletPeers(peerAddresses string, port string) ([]string, []error)

ParseWalletPeers is a convenience function that converts the provided peerAddresses string to an array of valid peer addresses.

func SortTxs added in v1.1.0

func SortTxs(txs []*Transaction, newestFirst bool)

SortTxs is a shared function that sorts the provided txs slice in ascending or descending order depending on newestFirst.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

func VerifySeed

func VerifySeed(seedMnemonic string, assetType utils.AssetType) bool

Types

type Account

type Account struct {
	// DCR fields
	ExternalKeyCount int32
	InternalKeyCount int32
	ImportedKeyCount int32

	// BTC fields
	AccountProperties

	// Has some fields common to both BTC and DCR
	WalletID int
	Balance  *Balance
	Number   int32
	Name     string
}

type AccountProperties

type AccountProperties struct {
	// AccountNumber is the internal number used to reference the account.
	AccountNumber uint32

	// AccountName is the user-identifying name of the account.
	AccountName string

	// ExternalKeyCount is the number of internal keys that have been
	// derived for the account.
	ExternalKeyCount uint32

	// InternalKeyCount is the number of internal keys that have been
	// derived for the account.
	InternalKeyCount uint32

	// ImportedKeyCount is the number of imported keys found within the
	// account.
	ImportedKeyCount uint32

	// AccountPubKey is the account's public key that can be used to
	// derive any address relevant to said account.
	//
	// NOTE: This may be nil for imported accounts.
	AccountPubKey *btchdkeychain.ExtendedKey // TODO: support LTC

	// MasterKeyFingerprint represents the fingerprint of the root key
	// corresponding to the master public key (also known as the key with
	// derivation path m/). This may be required by some hardware wallets
	// for proper identification and signing.
	MasterKeyFingerprint uint32

	// KeyScope is the key scope the account belongs to.
	KeyScope KeyScope

	// IsWatchOnly indicates whether the is set up as watch-only, i.e., it
	// doesn't contain any private key information.
	IsWatchOnly bool

	// AddrSchema, if non-nil, specifies an address schema override for
	// address generation only applicable to the account.
	AddrSchema *ScopeAddrSchema
}

AccountProperties contains properties associated with each account, such as the account name, number, and the nubmer of derived and imported keys.

type Accounts

type Accounts struct {
	Accounts           []*Account
	CurrentBlockHash   []byte
	CurrentBlockHeight int32
}

type AddressDiscoveryProgressReport

type AddressDiscoveryProgressReport struct {
	*GeneralSyncProgress
	AddressDiscoveryStartTime int64
	TotalDiscoveryTimeSpent   int64
	AddressDiscoveryProgress  int32 `json:"addressDiscoveryProgress"`
}

type AddressType

type AddressType uint8

AddressType represents the various address types waddrmgr is currently able to generate, and maintain.

NOTE: These MUST be stable as they're used for scope address schema recognition within the database.

type Amount

type Amount struct {
	// UnitValue holds the base monetary unit value for a cryptocurrency.
	// The field is currently used for both BTC, LTC and DCR.
	// For Decred it holds the number of Atoms per DCR.
	// For Bitcoin it holds the number of satoshis per BTC.
	// For Litecoin it holds the number of litoshis per LTC.
	UnitValue int64
	// CoinValue holds the monetary amount counted in a cryptocurrency base
	// units, converted to a floating point value representing the amount
	// of said cryptocurrency.
	CoinValue float64
}

type Asset

type Asset interface {
	Shutdown()
	IsSynced() bool
	IsSyncing() bool
	SpvSync() error
	CancelRescan()
	CancelSync()
	IsRescanning() bool
	RescanBlocks() error
	ConnectedPeers() int32
	RemovePeers()
	SetSpecificPeer(address string)
	GetExtendedPubKey(account int32) (string, error)
	IsSyncShuttingDown() bool

	LockWallet()
	IsLocked() bool
	IsWaiting() bool
	WalletOpened() bool
	OpenWallet() error
	GetWalletID() int
	GetWalletName() string
	IsWatchingOnlyWallet() bool
	UnlockWallet(string) error
	DeleteWallet(privPass string) error
	RenameWallet(newName string) error
	DecryptSeed(privatePassphrase string) (string, error)
	VerifySeedForWallet(seedMnemonic, privpass string) (bool, error)
	ChangePrivatePassphraseForWallet(oldPrivatePassphrase, newPrivatePassphrase string, privatePassphraseType int32) error

	RootDir() string
	DataDir() string
	GetEncryptedSeed() string
	IsConnectedToNetwork() bool
	NetType() utils.NetworkType
	ToAmount(v int64) AssetAmount
	GetAssetType() utils.AssetType
	Internal() *loader.LoadedWallets
	TargetTimePerBlockMinutes() float64
	RequiredConfirmations() int32
	ShutdownContextWithCancel() (context.Context, context.CancelFunc)
	LogFile() string

	PublishUnminedTransactions() error
	CountTransactions(txFilter int32) (int, error)
	GetTransactionRaw(txHash string) (*Transaction, error)
	TxMatchesFilter(tx *Transaction, txFilter int32) bool
	GetTransactionsRaw(offset, limit, txFilter int32, newestFirst bool, txHashSearch string) ([]*Transaction, error)

	GetBestBlock() *BlockInfo
	GetBestBlockHeight() int32
	GetBestBlockTimeStamp() int64

	ContainsDiscoveredAccounts() bool
	GetAccountsRaw() (*Accounts, error)
	GetAccount(accountNumber int32) (*Account, error)
	AccountName(accountNumber int32) (string, error)
	CreateNewAccount(accountName, privPass string) (int32, error)
	RenameAccount(accountNumber int32, newName string) error
	AccountNumber(accountName string) (int32, error)
	AccountNameRaw(accountNumber uint32) (string, error)
	GetAccountBalance(accountNumber int32) (*Balance, error)
	GetWalletBalance() (*Balance, error)
	UnspentOutputs(account int32) ([]*UnspentOutput, error)

	AddSyncProgressListener(syncProgressListener *SyncProgressListener, uniqueIdentifier string) error
	RemoveSyncProgressListener(uniqueIdentifier string)
	AddTxAndBlockNotificationListener(txAndBlockNotificationListener *TxAndBlockNotificationListener, uniqueIdentifier string) error
	RemoveTxAndBlockNotificationListener(uniqueIdentifier string)
	SetBlocksRescanProgressListener(blocksRescanProgressListener *BlocksRescanProgressListener)

	CurrentAddress(account int32) (string, error)
	NextAddress(account int32) (string, error)
	IsAddressValid(address string) bool
	HaveAddress(address string) bool

	SignMessage(passphrase, address, message string) ([]byte, error)
	VerifyMessage(address, message, signatureBase64 string) (bool, error)

	SaveUserConfigValue(key string, value interface{})
	ReadUserConfigValue(key string, valueOut interface{}) error

	SetBoolConfigValueForKey(key string, value bool)
	SetDoubleConfigValueForKey(key string, value float64)
	SetIntConfigValueForKey(key string, value int)
	SetInt32ConfigValueForKey(key string, value int32)
	SetLongConfigValueForKey(key string, value int64)
	SetStringConfigValueForKey(key, value string)

	ReadBoolConfigValueForKey(key string, defaultValue bool) bool
	ReadDoubleConfigValueForKey(key string, defaultValue float64) float64
	ReadIntConfigValueForKey(key string, defaultValue int) int
	ReadInt32ConfigValueForKey(key string, defaultValue int32) int32
	ReadLongConfigValueForKey(key string, defaultValue int64) int64
	ReadStringConfigValueForKey(key string, defaultValue string) string

	NewUnsignedTx(accountNumber int32, utxos []*UnspentOutput) error
	AddSendDestination(id int, address string, unitAmount int64, sendMax bool) error
	ComputeTxSizeEstimation(dstAddress string, utxos []*UnspentOutput) (int, error)
	Broadcast(passphrase, label string) ([]byte, error)
	EstimateFeeAndSize() (*TxFeeAndSize, error)
	IsUnsignedTxExist() bool
	RemoveSendDestination(id int)
	SendDestination(id int) *TransactionDestination
	UpdateSendDestination(id int, address string, atomAmount int64, sendMax bool) error
}

Asset defines the interface each wallet must satisfy.

type AssetAmount

type AssetAmount interface {
	// ToCoin returns an asset formatted amount in float64.
	ToCoin() float64
	// String returns an asset formatted amount in string.
	String() string
	// MulF64 multiplies an Amount by a floating point value.
	MulF64(f float64) AssetAmount
	// ToInt() returns the complete int64 value without formatting.
	ToInt() int64
}

type AuthInfo

type AuthInfo struct {
	Name            string
	PrivatePass     string
	PrivatePassType int32
}

AuthInfo defines the complete information required to either create a new wallet or restore an old wallet.

type Balance

type Balance struct {
	// Fields common to all assets.
	Total          AssetAmount
	Spendable      AssetAmount
	ImmatureReward AssetAmount
	Locked         AssetAmount

	// DCR only fields
	ImmatureStakeGeneration AssetAmount
	LockedByTickets         AssetAmount
	VotingAuthority         AssetAmount
	UnConfirmed             AssetAmount
}

type BlockInfo

type BlockInfo struct {
	Height    int32
	Timestamp int64
}

type BlocksRescanProgressListener

type BlocksRescanProgressListener struct {
	OnBlocksRescanStarted  func(walletID int)
	OnBlocksRescanProgress func(*HeadersRescanProgressReport)
	OnBlocksRescanEnded    func(walletID int, err error)
}

type CFiltersFetchProgressReport

type CFiltersFetchProgressReport struct {
	*GeneralSyncProgress
	BeginFetchCFiltersTimeStamp int64
	StartCFiltersHeight         int32
	CfiltersFetchTimeSpent      int64
	TotalFetchedCFiltersCount   int32
	TotalCFiltersToFetch        int32 `json:"totalCFiltersToFetch"`
	CurrentCFilterHeight        int32 `json:"currentCFilterHeight"`
	CFiltersFetchProgress       int32 `json:"headersFetchProgress"`
}

type ExchangeConfig

type ExchangeConfig struct {
	SourceAsset      utils.AssetType
	DestinationAsset utils.AssetType

	SourceWalletID      int32
	DestinationWalletID int32

	SourceAccountNumber      int32
	DestinationAccountNumber int32
}

ExchangeConfig defines configuration parameters for creating an exchange order.

type FeeEstimate

type FeeEstimate struct {
	// Number of confirmed blocks that show the average fee rate represented below.
	ConfirmedBlocks int32
	// Feerate shows estimate fee rate in Sat/kvB or Lit/kvB.
	Feerate AssetAmount
}

FeeEstimate defines the fee estimate returned by the API.

type GeneralSyncProgress

type GeneralSyncProgress struct {
	TotalSyncProgress         int32 `json:"totalSyncProgress"`
	TotalTimeRemainingSeconds int64 `json:"totalTimeRemainingSeconds"`
}

type HeadersFetchProgressReport

type HeadersFetchProgressReport struct {
	*GeneralSyncProgress
	HeadersFetchTimeSpent int64
	BeginFetchTimeStamp   time.Time
	StartHeaderHeight     *int32
	TotalHeadersToFetch   int32 `json:"totalHeadersToFetch"`
	HeadersFetchProgress  int32 `json:"headersFetchProgress"`
}

type HeadersRescanProgressReport

type HeadersRescanProgressReport struct {
	*GeneralSyncProgress
	TotalHeadersToScan  int32 `json:"totalHeadersToScan"`
	CurrentRescanHeight int32 `json:"currentRescanHeight"`
	RescanProgress      int32 `json:"rescanProgress"`
	RescanTimeRemaining int64 `json:"rescanTimeRemaining"`
	WalletID            int   `json:"walletID"`
}

type InitParams

type InitParams struct {
	RootDir     string
	NetType     utils.NetworkType
	DB          *storm.DB
	DbDriver    string
	LogDir      string
	DEXTestAddr string
}

InitParams defines the basic parameters required to instantiate any wallet interface.

type KeyScope

type KeyScope struct {
	// Purpose is the purpose of this key scope. This is the first child of
	// the master HD key.
	Purpose uint32

	// Coin is a value that represents the particular coin which is the
	// child of the purpose key. With this key, any accounts, or other
	// children can be derived at all.
	Coin uint32
}

KeyScope represents a restricted key scope from the primary root key within the HD chain. From the root manager (m/) we can create a nearly arbitrary number of ScopedKeyManagers of key derivation path: m/purpose'/cointype'. These scoped managers can then me managed indecently, as they house the encrypted cointype key and can derive any child keys from there on.

type PeerInfo

type PeerInfo struct {
	ID             int32  `json:"id"`
	Addr           string `json:"addr"`
	AddrLocal      string `json:"addr_local"`
	Services       string `json:"services"`
	Version        uint32 `json:"version"`
	SubVer         string `json:"sub_ver"`
	StartingHeight int64  `json:"starting_height"`
	BanScore       int32  `json:"ban_score"`
}

type ScopeAddrSchema

type ScopeAddrSchema struct {
	// ExternalAddrType is the address type for all keys within branch 0.
	ExternalAddrType AddressType

	// InternalAddrType is the address type for all keys within branch 1
	// (change addresses).
	InternalAddrType AddressType
}

ScopeAddrSchema is the address schema of a particular KeyScope. This will be persisted within the database, and will be consulted when deriving any keys for a particular scope to know how to encode the public keys as addresses.

type SyncProgressListener

type SyncProgressListener struct {
	OnSyncStarted                 func()
	OnPeerConnectedOrDisconnected func(numberOfConnectedPeers int32)
	OnCFiltersFetchProgress       func(cfiltersFetchProgress *CFiltersFetchProgressReport)
	OnHeadersFetchProgress        func(headersFetchProgress *HeadersFetchProgressReport)
	OnAddressDiscoveryProgress    func(addressDiscoveryProgress *AddressDiscoveryProgressReport)
	OnHeadersRescanProgress       func(headersRescanProgress *HeadersRescanProgressReport)
	OnSyncCompleted               func()
	OnSyncCanceled                func(willRestart bool)
	OnSyncEndedWithError          func(err error)
}

type Transaction

type Transaction struct {
	Hash          string `storm:"id,unique" json:"hash"`
	Type          string `storm:"index" json:"type,omitempty"`
	Hex           string `json:"hex"`
	Timestamp     int64  `storm:"index" json:"timestamp"`
	BlockHeight   int32  `storm:"index" json:"block_height"`
	TicketSpender string `storm:"index" json:"ticket_spender,omitempty"` // (DCR Field)

	MixDenomination int64 `json:"mix_denom,omitempty"` // (DCR Field)
	MixCount        int32 `json:"mix_count,omitempty"` // (DCR Field)

	Version  int32  `json:"version"`
	LockTime int32  `json:"lock_time"`
	Expiry   int32  `json:"expiry,omitempty"` // (DCR Field)
	Fee      int64  `json:"fee"`
	FeeRate  int64  `json:"fee_rate"`
	Size     int    `json:"size"`
	Label    string `json:"label"`

	Direction int32       `storm:"index" json:"direction"`
	Amount    int64       `json:"amount"`
	Inputs    []*TxInput  `json:"inputs"`
	Outputs   []*TxOutput `json:"outputs"`

	// Vote Info (DCR fields)
	VoteVersion        int32  `json:"vote_version,omitempty"`
	LastBlockValid     bool   `json:"last_block_valid,omitempty"`
	VoteBits           string `json:"vote_bits,omitempty"`
	VoteReward         int64  `json:"vote_reward,omitempty"`
	TicketSpentHash    string `storm:"unique" json:"ticket_spent_hash,omitempty"`
	DaysToVoteOrRevoke int32  `json:"days_to_vote_revoke,omitempty"`
}

Transaction is used with storm for tx indexing operations. For faster queries, the `Hash`, `Type` and `Direction` fields are indexed.

type TransactionDestination

type TransactionDestination struct {
	// Shared fields.
	ID         int
	Address    string
	SendMax    bool
	UnitAmount int64
}

type TransactionOverview

type TransactionOverview struct {
	All         int
	Sent        int
	Received    int
	Transferred int
	Mixed       int
	Staking     int
	Coinbase    int
}

type TxAndBlockNotificationListener

type TxAndBlockNotificationListener struct {
	OnTransaction          func(walletID int, transaction *Transaction)
	OnBlockAttached        func(walletID int, blockHeight int32)
	OnTransactionConfirmed func(walletID int, hash string, blockHeight int32)
}

type TxFeeAndSize

type TxFeeAndSize struct {
	Fee                 *Amount
	Change              *Amount
	FeeRate             int64 // calculated in Sat/kvB or Lit/kvB
	EstimatedSignedSize int
}

type TxInfoFromWallet

type TxInfoFromWallet struct {
	WalletID    int
	Hex         string
	Timestamp   int64
	BlockHeight int32
	Inputs      []*WInput
	Outputs     []*WOutput
}

TxInfoFromWallet contains tx data that relates to the querying wallet. This info is used with `DecodeTransaction` to compose the entire details of a transaction.

type TxInput

type TxInput struct {
	PreviousTransactionHash  string `json:"previous_transaction_hash"`
	PreviousTransactionIndex int32  `json:"previous_transaction_index"`
	PreviousOutpoint         string `json:"previous_outpoint"`
	Amount                   int64  `json:"amount"`
	AccountNumber            int32  `json:"account_number"`
}

type TxOutput

type TxOutput struct {
	Index         int32  `json:"index"`
	Amount        int64  `json:"amount"`
	Version       int32  `json:"version,omitempty"` // (DCR Field)
	ScriptType    string `json:"script_type"`
	Address       string `json:"address"`
	Internal      bool   `json:"internal"`
	AccountNumber int32  `json:"account_number"`
}

type UnsignedTransaction

type UnsignedTransaction struct {
	UnsignedTransaction       []byte
	EstimatedSignedSize       int
	ChangeIndex               int
	TotalOutputAmount         int64
	TotalPreviousOutputAmount int64
}

type UnspentOutput

type UnspentOutput struct {
	TxID          string
	Vout          uint32
	Address       string
	ScriptPubKey  string
	RedeemScript  string
	Amount        AssetAmount
	Confirmations int32
	Spendable     bool
	ReceiveTime   time.Time
	Tree          int8
}

UnspentOutput defines the unspent output parameters for coin selection.

type WAccount

type WAccount struct {
	AccountNumber int32  `json:"account_number"`
	AccountName   string `json:"account_name"`
}

type WConfig

type WConfig struct {
	// General
	GapLimit                uint32         // Allowed unused address gap between used addresses of accounts
	ManualTickets           bool           // Do not discover new tickets through network synchronization
	AllowHighFees           bool           // Do not perform high fee checks
	RelayFee                dcrutil.Amount // Transaction fee per kilobyte
	AccountGapLimit         int            // Allowed gap of unused accounts
	DisableCoinTypeUpgrades bool           // Never upgrade from legacy to SLIP0044 coin type keys

	// CSPP
	MixSplitLimit int // Connection limit to CoinShuffle++ server per change amount
}

WConfig defines options for configuring wallet behaviour. This is a subset of the config used by dcrwallet.

type WInput

type WInput struct {
	Index    int32 `json:"index"`
	AmountIn int64 `json:"amount_in"`
	*WAccount
}

type WOutput

type WOutput struct {
	Index     int32  `json:"index"`
	AmountOut int64  `json:"amount_out"`
	Internal  bool   `json:"internal"`
	Address   string `json:"address"`
	*WAccount
}

type Wallet

type Wallet struct {
	ID        int       `storm:"id,increment"`
	Name      string    `storm:"unique"`
	CreatedAt time.Time `storm:"index"`
	Type      utils.AssetType

	EncryptedSeed         []byte
	IsRestored            bool
	HasDiscoveredAccounts bool
	PrivatePassphraseType int32

	// Birthday holds the timestamp of the birthday block from where wallet
	// restoration begins from. CreatedAt is available for audit purposes
	// in relation to how long the wallet has been in existence.
	Birthday time.Time
	// contains filtered or unexported fields
}

func CreateNewWallet

func CreateNewWallet(pass *AuthInfo, loader loader.AssetLoader,
	params *InitParams, assetType utils.AssetType,
) (*Wallet, error)

func CreateWatchOnlyWallet

func CreateWatchOnlyWallet(walletName, extendedPublicKey string, loader loader.AssetLoader,
	params *InitParams, assetType utils.AssetType,
) (*Wallet, error)

func RestoreWallet

func RestoreWallet(seedMnemonic string, pass *AuthInfo, loader loader.AssetLoader,
	params *InitParams, assetType utils.AssetType,
) (*Wallet, error)

func (*Wallet) ChangePrivatePassphraseForWallet

func (wallet *Wallet) ChangePrivatePassphraseForWallet(oldPrivatePassphrase, newPrivatePassphrase string, privatePassphraseType int32) error

ChangePrivatePassphraseForWallet attempts to change the wallet's passphrase and re-encrypts the seed with the new passphrase.

func (*Wallet) ContainsDiscoveredAccounts

func (wallet *Wallet) ContainsDiscoveredAccounts() bool

func (*Wallet) DataDir

func (wallet *Wallet) DataDir() string

DataDir returns the current wallet bucket directory. It is exported via the interface thus the need to be thread safe.

func (*Wallet) DecryptSeed

func (wallet *Wallet) DecryptSeed(privatePassphrase string) (string, error)

DecryptSeed decrypts wallet.EncryptedSeed using privatePassphrase

func (*Wallet) DeleteUserConfigValueForKey

func (wallet *Wallet) DeleteUserConfigValueForKey(key string)

DeleteUserConfigValueForKey method deletes the value stored against the provided key at the asset level.

func (*Wallet) DeleteWallet

func (wallet *Wallet) DeleteWallet(privPass string) error

func (*Wallet) GetAssetType

func (wallet *Wallet) GetAssetType() utils.AssetType

GetAssetType returns the current wallet's asset type. It is exported via the interface thus the the need to be thread safe.

func (*Wallet) GetBirthday

func (wallet *Wallet) GetBirthday() time.Time

GetBirthday returns the timestamp when the wallet was created or its keys were first used. This helps to check if a wallet requires auto rescan and recovery on wallet startup.

func (*Wallet) GetEncryptedSeed

func (wallet *Wallet) GetEncryptedSeed() string

func (*Wallet) GetWalletDataDb

func (wallet *Wallet) GetWalletDataDb() *walletdata.DB

GetWalletDataDb returns the walletdatadb instance. Its not exported via the but nonetheless has been made thread safe.

func (*Wallet) GetWalletID

func (wallet *Wallet) GetWalletID() int

func (*Wallet) GetWalletName

func (wallet *Wallet) GetWalletName() string

func (*Wallet) Internal

func (wallet *Wallet) Internal() *loader.LoadedWallets

Internal return the upstream wallet of the current asset created in the loader package. Since its exported via the interface thus the need to be thread safe.

func (*Wallet) IsLocked

func (wallet *Wallet) IsLocked() bool

func (*Wallet) IsWatchingOnlyWallet

func (wallet *Wallet) IsWatchingOnlyWallet() bool

func (*Wallet) LockWallet

func (wallet *Wallet) LockWallet()

func (*Wallet) LogFile

func (wallet *Wallet) LogFile() string

func (*Wallet) MarkWalletAsDiscoveredAccounts

func (wallet *Wallet) MarkWalletAsDiscoveredAccounts() error

func (*Wallet) NetType

func (wallet *Wallet) NetType() utils.NetworkType

NetType returns the current network type. It is exported via the interface thus the the need to thread safe.

func (*Wallet) OpenWallet

func (wallet *Wallet) OpenWallet() error

func (*Wallet) Prepare

func (wallet *Wallet) Prepare(loader loader.AssetLoader, params *InitParams) (err error)

prepare gets a wallet ready for use by opening the transactions index database and initializing the wallet loader which can be used subsequently to create, load and unload the wallet.

func (*Wallet) ReadBoolConfigValueForKey

func (wallet *Wallet) ReadBoolConfigValueForKey(key string, defaultValue bool) (valueOut bool)

ReadBoolConfigValueForKey reads the boolean value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadDoubleConfigValueForKey

func (wallet *Wallet) ReadDoubleConfigValueForKey(key string, defaultValue float64) (valueOut float64)

ReadDoubleConfigValueForKey reads the float64 value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadInt32ConfigValueForKey

func (wallet *Wallet) ReadInt32ConfigValueForKey(key string, defaultValue int32) (valueOut int32)

ReadInt32ConfigValueForKey int32 the boolean value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadIntConfigValueForKey

func (wallet *Wallet) ReadIntConfigValueForKey(key string, defaultValue int) (valueOut int)

ReadIntConfigValueForKey reads the int value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadLongConfigValueForKey

func (wallet *Wallet) ReadLongConfigValueForKey(key string, defaultValue int64) (valueOut int64)

ReadLongConfigValueForKey reads the int64 value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadStringConfigValueForKey

func (wallet *Wallet) ReadStringConfigValueForKey(key string, defaultValue string) (valueOut string)

ReadStringConfigValueForKey reads the string value stored against the provided key at the asset level. Provided default value is returned if the key is not found.

func (*Wallet) ReadUserConfigValue

func (wallet *Wallet) ReadUserConfigValue(key string, valueOut interface{}) error

ReadUserConfigValue reads the generic value stored against the provided key at the asset level.

func (*Wallet) RenameWallet

func (wallet *Wallet) RenameWallet(newName string) error

func (*Wallet) RequiredConfirmations

func (wallet *Wallet) RequiredConfirmations() int32

RequiredConfirmations specifies the minimum number of confirmations a transaction needs to be consider as confirmed.

func (*Wallet) RootDir

func (wallet *Wallet) RootDir() string

RootDir returns the root of current wallet bucket. It is exported via the interface thus the need to be thread safe. RootD

func (*Wallet) SaveUserConfigValue

func (wallet *Wallet) SaveUserConfigValue(key string, value interface{})

SaveUserConfigValue stores the generic value against the provided key at the asset level.

func (*Wallet) SetBirthday

func (wallet *Wallet) SetBirthday(birthday time.Time)

SetBirthday allows updating the birthday time to a more precise value that is verified by the network.

func (*Wallet) SetBoolConfigValueForKey

func (wallet *Wallet) SetBoolConfigValueForKey(key string, value bool)

SetBoolConfigValueForKey stores the boolean value against the provided key at the asset level.

func (*Wallet) SetDoubleConfigValueForKey

func (wallet *Wallet) SetDoubleConfigValueForKey(key string, value float64)

SetDoubleConfigValueForKey stores the float64 value against the provided key at the asset level.

func (*Wallet) SetInt32ConfigValueForKey

func (wallet *Wallet) SetInt32ConfigValueForKey(key string, value int32)

SetInt32ConfigValueForKey stores the int32 value against the provided key at the asset level.

func (*Wallet) SetIntConfigValueForKey

func (wallet *Wallet) SetIntConfigValueForKey(key string, value int)

SetIntConfigValueForKey stores the int value against the provided key at the asset level.

func (*Wallet) SetLongConfigValueForKey

func (wallet *Wallet) SetLongConfigValueForKey(key string, value int64)

SetLongConfigValueForKey stores the int64 value against the provided key at the asset level.

func (*Wallet) SetNetType

func (wallet *Wallet) SetNetType(netType utils.NetworkType)

SetNetType is used to set the net type if it doesn't exist. This method is used before the actual wallet is loaded otherwise once loaded the nettype can't be altered. This method help create the full method with the unique path for the folder structure for the testnet data dirs.

func (*Wallet) SetNetworkCancelCallback

func (wallet *Wallet) SetNetworkCancelCallback(callback func())

func (*Wallet) SetStringConfigValueForKey

func (wallet *Wallet) SetStringConfigValueForKey(key, value string)

SetStringConfigValueForKey stores the string value against the provided key at the asset level.

func (*Wallet) Shutdown

func (wallet *Wallet) Shutdown()

func (*Wallet) ShutdownContextWithCancel

func (wallet *Wallet) ShutdownContextWithCancel() (context.Context, context.CancelFunc)

func (*Wallet) TargetTimePerBlockMinutes

func (wallet *Wallet) TargetTimePerBlockMinutes() float64

func (*Wallet) UnlockWallet

func (wallet *Wallet) UnlockWallet(privPass string) (err error)

func (*Wallet) VerifySeedForWallet

func (wallet *Wallet) VerifySeedForWallet(seedMnemonic, privpass string) (bool, error)

VerifySeedForWallet compares seedMnemonic with the decrypted wallet.EncryptedSeed and clears wallet.EncryptedSeed if they match.

func (*Wallet) WalletCreationTimeInMillis

func (wallet *Wallet) WalletCreationTimeInMillis() (int64, error)

WalletCreationTimeInMillis returns the wallet creation time for new wallets. Restored wallets would return an error.

func (*Wallet) WalletExists

func (wallet *Wallet) WalletExists() (bool, error)

func (*Wallet) WalletNameExists

func (wallet *Wallet) WalletNameExists(walletName string) (bool, error)

func (*Wallet) WalletOpened

func (wallet *Wallet) WalletOpened() bool

WalletOpened checks if the upstream loader instance of the asset wallet is loaded (i.e. open).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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