[#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 `<wallet/wallet.h>` [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_wtx = nullptr, bool rescanning_old_block = false); ---- == Return Value the recently added wtx pointer or nullptr if there was a db write error. == 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_wtx* | optional callback to update the wallet transaction metadata | *rescanning_old_block* | true if the transaction was found during a rescan of old blocks |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#