Bitcoin Core  22.99.0
P2P Digital Currency
Functions | Variables
wallet.cpp File Reference
#include <wallet/wallet.h>
#include <chain.h>
#include <consensus/consensus.h>
#include <consensus/validation.h>
#include <external_signer.h>
#include <fs.h>
#include <interfaces/chain.h>
#include <interfaces/wallet.h>
#include <key.h>
#include <key_io.h>
#include <outputtype.h>
#include <policy/fees.h>
#include <policy/policy.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <psbt.h>
#include <script/descriptor.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <txmempool.h>
#include <util/bip32.h>
#include <util/check.h>
#include <util/error.h>
#include <util/fees.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/string.h>
#include <util/translation.h>
#include <wallet/coincontrol.h>
#include <wallet/fees.h>
#include <wallet/external_signer_scriptpubkeyman.h>
#include <univalue.h>
#include <algorithm>
#include <assert.h>
#include <optional>
#include <boost/algorithm/string/replace.hpp>
Include dependency graph for wallet.cpp:

Go to the source code of this file.

Functions

static std::vector< std::shared_ptr< CWallet > > vpwallets GUARDED_BY (cs_wallets)
 
bool AddWalletSetting (interfaces::Chain &chain, const std::string &wallet_name)
 Add wallet name to persistent configuration so it will be loaded on startup. More...
 
bool RemoveWalletSetting (interfaces::Chain &chain, const std::string &wallet_name)
 Remove wallet name from persistent configuration so it will not be loaded on startup. More...
 
static void UpdateWalletSetting (interfaces::Chain &chain, const std::string &wallet_name, std::optional< bool > load_on_startup, std::vector< bilingual_str > &warnings)
 
bool AddWallet (const std::shared_ptr< CWallet > &wallet)
 
bool RemoveWallet (const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
 
bool RemoveWallet (const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start)
 
std::vector< std::shared_ptr< CWallet > > GetWallets ()
 
std::shared_ptr< CWalletGetWallet (const std::string &name)
 
std::unique_ptr< interfaces::HandlerHandleLoadWallet (LoadWalletFn load_wallet)
 
static std::set< std::string > g_loading_wallet_set GUARDED_BY (g_loading_wallet_mutex)
 
static std::set< std::string > g_unloading_wallet_set GUARDED_BY (g_wallet_release_mutex)
 
static void ReleaseWallet (CWallet *wallet)
 
void UnloadWallet (std::shared_ptr< CWallet > &&wallet)
 Explicitly unload and delete the wallet. More...
 
std::shared_ptr< CWalletLoadWallet (interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
 
std::shared_ptr< CWalletCreateWallet (interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
 
void MaybeResendWalletTxs ()
 Called periodically by the schedule thread. More...
 
std::unique_ptr< WalletDatabaseMakeWalletDatabase (const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
 

Variables

const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
 
RecursiveMutex cs_wallets
 
static Mutex g_loading_wallet_mutex
 
static Mutex g_wallet_release_mutex
 
static std::condition_variable g_wallet_release_cv
 

Function Documentation

◆ AddWallet()

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

Definition at line 97 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddWalletSetting()

bool AddWalletSetting ( interfaces::Chain chain,
const std::string &  wallet_name 
)

Add wallet name to persistent configuration so it will be loaded on startup.

Definition at line 61 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateWallet()

std::shared_ptr<CWallet> CreateWallet ( interfaces::Chain chain,
const std::string &  name,
std::optional< bool >  load_on_start,
DatabaseOptions options,
DatabaseStatus status,
bilingual_str error,
std::vector< bilingual_str > &  warnings 
)

Definition at line 250 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWallet()

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

Definition at line 141 of file wallet.cpp.

Here is the caller graph for this function:

◆ GetWallets()

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

Definition at line 135 of file wallet.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY() [1/3]

static std::list< LoadWalletFn > g_load_wallet_fns GUARDED_BY ( cs_wallets  )
static

◆ GUARDED_BY() [2/3]

static std::set<std::string> g_loading_wallet_set GUARDED_BY ( g_loading_wallet_mutex  )
static

◆ GUARDED_BY() [3/3]

static std::set<std::string> g_unloading_wallet_set GUARDED_BY ( g_wallet_release_mutex  )
static

◆ HandleLoadWallet()

std::unique_ptr<interfaces::Handler> HandleLoadWallet ( LoadWalletFn  load_wallet)

Definition at line 150 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadWallet()

std::shared_ptr<CWallet> LoadWallet ( interfaces::Chain chain,
const std::string &  name,
std::optional< bool >  load_on_start,
const DatabaseOptions options,
DatabaseStatus status,
bilingual_str error,
std::vector< bilingual_str > &  warnings 
)

Definition at line 237 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeWalletDatabase()

std::unique_ptr<WalletDatabase> MakeWalletDatabase ( const std::string &  name,
const DatabaseOptions options,
DatabaseStatus status,
bilingual_str error_string 
)

Definition at line 2481 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Definition at line 1798 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReleaseWallet()

static void ReleaseWallet ( CWallet wallet)
static

Definition at line 164 of file wallet.cpp.

Here is the caller graph for this function:

◆ RemoveWallet() [1/2]

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

Definition at line 129 of file wallet.cpp.

Here is the call graph for this function:

◆ RemoveWallet() [2/2]

bool RemoveWallet ( const std::shared_ptr< CWallet > &  wallet,
std::optional< bool >  load_on_start,
std::vector< bilingual_str > &  warnings 
)

Definition at line 109 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveWalletSetting()

bool RemoveWalletSetting ( interfaces::Chain chain,
const std::string &  wallet_name 
)

Remove wallet name from persistent configuration so it will not be loaded on startup.

Definition at line 72 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Definition at line 181 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateWalletSetting()

static void UpdateWalletSetting ( interfaces::Chain chain,
const std::string &  wallet_name,
std::optional< bool >  load_on_startup,
std::vector< bilingual_str > &  warnings 
)
static

Definition at line 84 of file wallet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cs_wallets

RecursiveMutex cs_wallets

Definition at line 57 of file wallet.cpp.

◆ g_loading_wallet_mutex

Mutex g_loading_wallet_mutex
static

Definition at line 157 of file wallet.cpp.

◆ g_wallet_release_cv

std::condition_variable g_wallet_release_cv
static

Definition at line 159 of file wallet.cpp.

◆ g_wallet_release_mutex

Mutex g_wallet_release_mutex
static

Definition at line 158 of file wallet.cpp.

◆ WALLET_FLAG_CAVEATS

const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS
Initial value:
{
"You need to rescan the blockchain in order to correctly mark used "
"destinations in the past. Until this is done, some destinations may "
"be considered unused, even if the opposite is the case."
},
}

Definition at line 49 of file wallet.cpp.

WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:41