aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2024-02-08 12:34:26 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2024-02-12 16:05:14 -0300
commitcf4d72a75e9603e947b3d47e1f3ac7c7f37bb401 (patch)
tree7ba3c8cd493d1d523d647cf44fabe439ee29b4b8 /src/wallet/wallet.cpp
parent6ff0aa089c01ff3e610ecb47814ed739d685a14c (diff)
downloadbitcoin-cf4d72a75e9603e947b3d47e1f3ac7c7f37bb401.tar.xz
wallet: db, introduce 'RunWithinTxn()' helper function
'RunWithinTxn()' provides a way to execute db operations within a transactional context. It avoids writing repetitive boilerplate code for starting and committing the database transaction.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 11203ca3a4..db5f54cbb7 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2411,8 +2411,9 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
bool CWallet::DelAddressBook(const CTxDestination& address)
{
- WalletBatch batch(GetDatabase());
- return DelAddressBookWithDB(batch, address);
+ return RunWithinTxn(GetDatabase(), /*process_desc=*/"address book entry removal", [&](WalletBatch& batch){
+ return DelAddressBookWithDB(batch, address);
+ });
}
bool CWallet::DelAddressBookWithDB(WalletBatch& batch, const CTxDestination& address)