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

Add the transaction to the wallet, wrapping it up inside a CWalletTx

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:wallet/CWalletTx.adoc[CWalletTx]*
AddToWallet(
    xref:CTransactionRef.adoc[CTransactionRef] tx,
    xref:wallet/TxState.adoc[TxState] const& state,
    xref:wallet/CWallet/UpdateWalletTxFn.adoc[UpdateWalletTxFn] const& update&lowbar;wtx = nullptr,
    bool rescanning&lowbar;old&lowbar;block = false);
----

== Return Value

the recently added wtx pointer or nullptr if there was a db write error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *tx*
| the transaction to add
| *state*
| the chain state (block or mempool) in which the transaction was seen
| *update&lowbar;wtx*
| optional callback to update the wallet transaction metadata
| *rescanning&lowbar;old&lowbar;block*
| true if the transaction was found during a rescan of old blocks
|===


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