[#wallet-WalletContext]
= xref:wallet.adoc[wallet]::WalletContext
:relfileprefix: ../
:mrdocs:

WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets&period;

== Synopsis

Declared in `&lt;wallet&sol;context&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct WalletContext;
----

== Description

Future shared state can be added here as an alternative to adding global variables&period;

The struct isn&apos;t intended to have any member functions&period; It should just be a collection of state pointers that doesn&apos;t pull in dependencies or implement behavior&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:wallet/WalletContext/2constructor.adoc[`WalletContext`]         [.small]#[constructor]#
| Declare default constructor and destructor that are not inline, so code instantiating the WalletContext struct doesn&apos;t need to &num;include class definitions for smart pointer and container members&period;
| xref:wallet/WalletContext/2destructor.adoc[`&#126;WalletContext`] [.small]#[destructor]#
| Destroys the wallet context&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:wallet/WalletContext/args.adoc[`args`] 
| Command&hyphen;line and configuration arguments&period;
| xref:wallet/WalletContext/chain.adoc[`chain`] 
| Interface to the blockchain, shared by all wallets&period;
| xref:wallet/WalletContext/scheduler.adoc[`scheduler`] 
| Scheduler used to run periodic wallet tasks&period;
| xref:wallet/WalletContext/wallet_load_fns.adoc[`wallet&lowbar;load&lowbar;fns`] 
| Callbacks invoked when a wallet is loaded&period;
| xref:wallet/WalletContext/wallets.adoc[`wallets`] 
| The currently opened wallets&period;
| xref:wallet/WalletContext/wallets_mutex.adoc[`wallets&lowbar;mutex`] 
| Guards the list of opened wallets and load callbacks&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:wallet/AddWallet.adoc[`AddWallet`]
| Register a loaded wallet with the wallet context&period;
| xref:wallet/CreateWallet.adoc[`CreateWallet`]
| Create a new wallet and load it into the context&period;
| xref:wallet/EnsureWalletContext.adoc[`EnsureWalletContext`]
| Retrieves the WalletContext stored in an RPC context, throwing if absent&period;
| xref:wallet/GetDefaultWallet.adoc[`GetDefaultWallet`]
| Return the default wallet and report how many wallets are loaded&period;
| xref:wallet/GetWallet.adoc[`GetWallet`]
| Look up a loaded wallet by name&period;
| xref:wallet/GetWallets.adoc[`GetWallets`]
| Return all wallets currently loaded in the context&period;
| xref:wallet/HandleLoadWallet.adoc[`HandleLoadWallet`]
| Register a callback invoked whenever a wallet is loaded&period;
| xref:wallet/LoadWallet.adoc[`LoadWallet`]
| Load an existing wallet from disk into the context&period;
| xref:wallet/LoadWallets.adoc[`LoadWallets`]
| Load wallet databases&period;
| xref:wallet/MaybeResendWalletTxs.adoc[`MaybeResendWalletTxs`]
| Called periodically by the schedule thread&period; Prompts individual wallets to resend their transactions&period; Actual rebroadcast schedule is managed by the wallets themselves&period;
| xref:wallet/NotifyWalletLoaded.adoc[`NotifyWalletLoaded`]
| Fire the load&hyphen;wallet callbacks for a newly loaded wallet&period;
| xref:wallet/RemoveWallet-01.adoc[`RemoveWallet`]
| Remove a wallet from the wallet context and optionally update its load&hyphen;on&hyphen;startup setting&period;
| xref:wallet/RemoveWallet-05.adoc[`RemoveWallet`]
| Remove a wallet from the wallet context and optionally update its load&hyphen;on&hyphen;startup setting&period;
| xref:wallet/RestoreWallet.adoc[`RestoreWallet`]
| Restore a wallet from a backup file&period;
| xref:wallet/StartWallets.adoc[`StartWallets`]
| Complete startup of wallets&period;
| xref:wallet/UnloadWallets.adoc[`UnloadWallets`]
| Stop and unload all wallets held by the context&period;
| xref:wallet/VerifyWallets.adoc[`VerifyWallets`]
| Responsible for reading and validating the &hyphen;wallet arguments and verifying the wallet database&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
