Bitcoin
Classes | Typedefs | Enumerations | Functions | Variables
wallet.h File Reference
#include <amount.h>
#include <interfaces/chain.h>
#include <interfaces/handler.h>
#include <outputtype.h>
#include <policy/feerate.h>
#include <script/sign.h>
#include <streams.h>
#include <tinyformat.h>
#include <ui_interface.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <validationinterface.h>
#include <wallet/coinselection.h>
#include <wallet/crypter.h>
#include <wallet/ismine.h>
#include <wallet/walletdb.h>
#include <wallet/walletutil.h>
#include <algorithm>
#include <atomic>
#include <map>
#include <memory>
#include <set>
#include <stdexcept>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <boost/signals2/signal.hpp>

Go to the source code of this file.

Classes

class  CKeyPool
 
class  ReserveDestination
 
class  CAddressBookData
 
struct  CRecipient
 
struct  COutputEntry
 
class  CMerkleTx
 
class  CWalletTx
 
class  COutput
 
class  CWalletKey
 
struct  CoinSelectionParams
 
class  CWallet
 
struct  CWallet::ScanResult
 
struct  CWallet::Balance
 
class  WalletRescanReserver
 

Typedefs

typedef std::map< std::string, std::string > mapValue_t
 

Enumerations

enum  WalletCreationStatus { SUCCESS, CREATION_FAILED, ENCRYPTION_FAILED }
 
enum  WalletFeature {
  FEATURE_BASE = 10500, FEATURE_WALLETCRYPT = 40000, FEATURE_COMPRPUBKEY = 60000, FEATURE_HD = 130000,
  FEATURE_HD_SPLIT = 139900, FEATURE_NO_DEFAULT_KEY = 159900, FEATURE_PRE_SPLIT_KEYPOOL = 169900, FEATURE_LATEST = FEATURE_PRE_SPLIT_KEYPOOL
}
 
enum  WalletFlags : uint64_t { WALLET_FLAG_AVOID_REUSE = (1ULL << 0), WALLET_FLAG_KEY_ORIGIN_METADATA = (1ULL << 1), WALLET_FLAG_DISABLE_PRIVATE_KEYS = (1ULL << 32), WALLET_FLAG_BLANK_WALLET = (1ULL << 33) }
 

Functions

void UnloadWallet (std::shared_ptr< CWallet > &&wallet)
 
bool AddWallet (const std::shared_ptr< CWallet > &wallet)
 
bool RemoveWallet (const std::shared_ptr< CWallet > &wallet)
 
bool HasWallets ()
 
std::vector< std::shared_ptr< CWallet > > GetWallets ()
 
std::shared_ptr< CWalletGetWallet (const std::string &name)
 
std::shared_ptr< CWalletLoadWallet (interfaces::Chain &chain, const WalletLocation &location, std::string &error, std::string &warning)
 
std::shared_ptr< CWalletCreateWallet (interfaces::Chain &chain, const std::string &name, std::string &error, std::string &warning, WalletCreationStatus &status, const SecureString &passphrase, uint64_t wallet_creation_flags)
 
static void ReadOrderPos (int64_t &nOrderPos, mapValue_t &mapValue)
 
static void WriteOrderPos (const int64_t &nOrderPos, mapValue_t &mapValue)
 
int CalculateMaximumSignedInputSize (const CTxOut &txout, const CWallet *pwallet, bool use_max_sig=false)
 
void MaybeResendWalletTxs ()
 
int64_t CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, bool use_max_sig=false) EXCLUSIVE_LOCKS_REQUIRED(wallet -> cs_wallet)
 
int64_t CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, bool use_max_sig=false)
 

Variables

static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000
 Default for -keypool. More...
 
constexpr CAmount DEFAULT_PAY_TX_FEE = 0
 -paytxfee default More...
 
static const CAmount DEFAULT_FALLBACK_FEE = 20000
 -fallbackfee default More...
 
static const CAmount DEFAULT_DISCARD_FEE = 10000
 -discardfee default More...
 
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000
 -mintxfee default More...
 
static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000
 minimum recommended increment for BIP 125 replacement txs More...
 
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true
 Default for -spendzeroconfchange. More...
 
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false
 Default for -walletrejectlongchains. More...
 
static const bool DEFAULT_AVOIDPARTIALSPENDS = false
 Default for -avoidpartialspends. More...
 
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6
 -txconfirmtarget default More...
 
static const bool DEFAULT_WALLET_RBF = false
 -walletrbf default More...
 
static const bool DEFAULT_WALLETBROADCAST = true
 
static const bool DEFAULT_DISABLE_WALLET = false
 
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE {COIN / 10}
 -maxtxfee default More...
 
constexpr CAmount HIGH_TX_FEE_PER_KB {COIN / 100}
 Discourage users to set fees higher than this amount (in satoshis) per kB. More...
 
constexpr CAmount HIGH_MAX_TX_FEE {100 * HIGH_TX_FEE_PER_KB}
 -maxtxfee will warn if called with a higher fee than this amount (in satoshis) More...
 
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91
 Pre-calculated constants for input size estimation in virtual size More...
 
constexpr OutputType DEFAULT_ADDRESS_TYPE {OutputType::P2SH_SEGWIT}
 Default for -addresstype. More...
 
constexpr OutputType DEFAULT_CHANGE_TYPE {OutputType::CHANGE_AUTO}
 Default for -changetype. More...
 
static constexpr uint64_t KNOWN_WALLET_FLAGS
 
static constexpr uint64_t MUTABLE_WALLET_FLAGS
 
static const std::map< std::string, WalletFlagsWALLET_FLAG_MAP
 
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
 

Typedef Documentation

◆ mapValue_t

typedef std::map<std::string, std::string> mapValue_t

Enumeration Type Documentation

◆ WalletCreationStatus

Enumerator
SUCCESS 
CREATION_FAILED 
ENCRYPTION_FAILED 

◆ WalletFeature

(client) version numbers for particular wallet features

Enumerator
FEATURE_BASE 
FEATURE_WALLETCRYPT 
FEATURE_COMPRPUBKEY 
FEATURE_HD 
FEATURE_HD_SPLIT 
FEATURE_NO_DEFAULT_KEY 
FEATURE_PRE_SPLIT_KEYPOOL 
FEATURE_LATEST 

◆ WalletFlags

Enumerator
WALLET_FLAG_AVOID_REUSE 
WALLET_FLAG_KEY_ORIGIN_METADATA 
WALLET_FLAG_DISABLE_PRIVATE_KEYS 
WALLET_FLAG_BLANK_WALLET 

Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank."

The only function this flag serves is to distinguish a blank wallet from a newly created wallet when the wallet database is loaded, to avoid initialization that should only happen on first run.

This flag is also a mandatory flag to prevent previous versions of bitcoin from opening the wallet, thinking it was newly created, and then improperly reinitializing it.

Function Documentation

◆ AddWallet()

bool AddWallet ( const std::shared_ptr< CWallet > &  wallet)

◆ CreateWallet()

std::shared_ptr<CWallet> CreateWallet ( interfaces::Chain chain,
const std::string &  name,
std::string &  error,
std::string &  warning,
WalletCreationStatus status,
const SecureString passphrase,
uint64_t  wallet_creation_flags 
)

◆ GetWallet()

std::shared_ptr<CWallet> GetWallet ( const std::string &  name)

◆ GetWallets()

std::vector<std::shared_ptr<CWallet> > GetWallets ( )

◆ HasWallets()

bool HasWallets ( )

◆ LoadWallet()

std::shared_ptr<CWallet> LoadWallet ( interfaces::Chain chain,
const WalletLocation location,
std::string &  error,
std::string &  warning 
)

◆ MaybeResendWalletTxs()

void MaybeResendWalletTxs ( )

Called periodically by the schedule thread. Prompts individual wallets to resend their transactions. Actual rebroadcast schedule is managed by the wallets themselves.

◆ ReadOrderPos()

static void ReadOrderPos ( int64_t nOrderPos,
mapValue_t mapValue 
)
inlinestatic

◆ RemoveWallet()

bool RemoveWallet ( const std::shared_ptr< CWallet > &  wallet)

◆ UnloadWallet()

void UnloadWallet ( std::shared_ptr< CWallet > &&  wallet)

Explicitly unload and delete the wallet. Blocks the current thread after signaling the unload intent so that all wallet clients release the wallet. Note that, when blocking is not required, the wallet is implicitly unloaded by the shared pointer deleter.

◆ WriteOrderPos()

static void WriteOrderPos ( const int64_t nOrderPos,
mapValue_t mapValue 
)
inlinestatic

Variable Documentation

◆ DEFAULT_ADDRESS_TYPE

constexpr OutputType DEFAULT_ADDRESS_TYPE {OutputType::P2SH_SEGWIT}

Default for -addresstype.

◆ DEFAULT_AVOIDPARTIALSPENDS

const bool DEFAULT_AVOIDPARTIALSPENDS = false
static

Default for -avoidpartialspends.

◆ DEFAULT_CHANGE_TYPE

constexpr OutputType DEFAULT_CHANGE_TYPE {OutputType::CHANGE_AUTO}

Default for -changetype.

◆ DEFAULT_DISABLE_WALLET

const bool DEFAULT_DISABLE_WALLET = false
static

◆ DEFAULT_DISCARD_FEE

const CAmount DEFAULT_DISCARD_FEE = 10000
static

-discardfee default

◆ DEFAULT_FALLBACK_FEE

const CAmount DEFAULT_FALLBACK_FEE = 20000
static

-fallbackfee default

◆ DEFAULT_KEYPOOL_SIZE

const unsigned int DEFAULT_KEYPOOL_SIZE = 1000
static

Default for -keypool.

◆ DEFAULT_PAY_TX_FEE

constexpr CAmount DEFAULT_PAY_TX_FEE = 0

-paytxfee default

◆ DEFAULT_SPEND_ZEROCONF_CHANGE

const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true
static

Default for -spendzeroconfchange.

◆ DEFAULT_TRANSACTION_MAXFEE

constexpr CAmount DEFAULT_TRANSACTION_MAXFEE {COIN / 10}

-maxtxfee default

◆ DEFAULT_TRANSACTION_MINFEE

const CAmount DEFAULT_TRANSACTION_MINFEE = 1000
static

-mintxfee default

◆ DEFAULT_TX_CONFIRM_TARGET

const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6
static

-txconfirmtarget default

◆ DEFAULT_WALLET_RBF

const bool DEFAULT_WALLET_RBF = false
static

-walletrbf default

◆ DEFAULT_WALLET_REJECT_LONG_CHAINS

const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false
static

Default for -walletrejectlongchains.

◆ DEFAULT_WALLETBROADCAST

const bool DEFAULT_WALLETBROADCAST = true
static

◆ DUMMY_NESTED_P2WPKH_INPUT_SIZE

constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91
static

Pre-calculated constants for input size estimation in virtual size

◆ HIGH_MAX_TX_FEE

constexpr CAmount HIGH_MAX_TX_FEE {100 * HIGH_TX_FEE_PER_KB}

-maxtxfee will warn if called with a higher fee than this amount (in satoshis)

◆ HIGH_TX_FEE_PER_KB

constexpr CAmount HIGH_TX_FEE_PER_KB {COIN / 100}

Discourage users to set fees higher than this amount (in satoshis) per kB.

◆ KNOWN_WALLET_FLAGS

constexpr uint64_t KNOWN_WALLET_FLAGS
static

◆ MUTABLE_WALLET_FLAGS

constexpr uint64_t MUTABLE_WALLET_FLAGS
static
Initial value:

◆ WALLET_FLAG_CAVEATS

const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS

◆ WALLET_FLAG_MAP

const std::map<std::string,WalletFlags> WALLET_FLAG_MAP
static
Initial value:
{
{"avoid_reuse", WALLET_FLAG_AVOID_REUSE},
{"key_origin_metadata", WALLET_FLAG_KEY_ORIGIN_METADATA},
{"disable_private_keys", WALLET_FLAG_DISABLE_PRIVATE_KEYS},
}
Definition: wallet.h:153
Definition: wallet.h:138
Definition: wallet.h:135
Definition: wallet.h:141

◆ WALLET_INCREMENTAL_RELAY_FEE

const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000
static

minimum recommended increment for BIP 125 replacement txs