aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2016-12-19 11:25:15 -0500
committerRussell Yanofsky <russ@yanofsky.org>2020-05-01 05:59:09 -0500
commit2b9cba206594bfbcefcef0c88a0bf793819643bd (patch)
treeb2a2f7ffb44094dd43e234f87cf6da579d315c89 /src/wallet/wallet.h
parent608359b071dac82a9cf33a6c9e01f87abfcb90eb (diff)
downloadbitcoin-2b9cba206594bfbcefcef0c88a0bf793819643bd.tar.xz
Remove CWalletTx merging logic from AddToWallet
Instead of AddToWallet taking a temporary CWalletTx object and then potentially merging it with a pre-existing CWalletTx, have it take a callback so callers can update the pre-existing CWalletTx directly. This makes AddToWallet simpler because now it is only has to be concerned with saving CWalletTx objects and not merging them. This makes AddToWallet calls clearer because they can now make direct updates to CWalletTx entries without having to make temporary objects and then worry about how they will be merged. This is a pure refactoring, no behavior is changing.
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 72b3cf1fb8..b1ae975bd8 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -886,7 +886,16 @@ public:
DBErrors ReorderTransactions();
void MarkDirty();
- bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
+
+ //! Callback for updating transaction metadata in mapWallet.
+ //!
+ //! @param wtx - reference to mapWallet transaction to update
+ //! @param new_tx - true if wtx is newly inserted, false if it previously existed
+ //!
+ //! @return true if wtx is changed and needs to be saved to disk, otherwise false
+ using UpdateWalletTxFn = std::function<bool(CWalletTx& wtx, bool new_tx)>;
+
+ CWalletTx* AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation& confirm, const UpdateWalletTxFn& update_wtx=nullptr, bool fFlushOnClose=true);
void LoadToWallet(CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void transactionAddedToMempool(const CTransactionRef& tx) override;
void blockConnected(const CBlock& block, int height) override;