Skip to content

Commit 240d8ef

Browse files
fanquakeknst
authored andcommitted
Merge bitcoin#22358: Remove unused wallet pointer from wallet signals
8888cf4 Remove unused wallet pointer from NotifyAddressBookChanged (MarcoFalke) faf3640 Remove unused wallet pointer from NotifyTransactionChanged signal (MarcoFalke) Pull request description: The signals are members of the wallet, so passing the pointer would be redundant even if it was used. Also, fix `with` -> `without`, which was forgotten in commit ca4cf5c. ACKs for top commit: jonatack: Code review ACK 8888cf4 also verified with/without lock cs_wallet status for each of the two functions and debian clang 11 debug build clean promag: Code review ACK 8888cf4. theStack: Code review ACK 8888cf4 Tree-SHA512: e3b80931ce9bcb05213619f5435ac7c21d3c7848643950a70db610902bd1803c92bb75e501d46b0e519bc576901f160e088e8882c4f1adce892a80df565f897b
1 parent 9a1500a commit 240d8ef

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/qt/test/wallettests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
6464
entry->findChild<QValidatedLineEdit*>("payTo")->setText(QString::fromStdString(EncodeDestination(address)));
6565
entry->findChild<BitcoinAmountField*>("payAmount")->setValue(amount);
6666
uint256 txid;
67-
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](CWallet*, const uint256& hash, ChangeType status) {
67+
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const uint256& hash, ChangeType status) {
6868
if (status == CT_NEW) txid = hash;
6969
}));
7070
ConfirmSend();

src/wallet/interfaces.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,13 @@ class WalletImpl : public Wallet
524524
std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) override
525525
{
526526
return MakeHandler(m_wallet->NotifyAddressBookChanged.connect(
527-
[fn](CWallet*, const CTxDestination& address, const std::string& label, bool is_mine,
528-
const std::string& purpose, ChangeType status) { fn(address, label, is_mine, purpose, status); }));
527+
[fn](const CTxDestination& address, const std::string& label, bool is_mine,
528+
const std::string& purpose, ChangeType status) { fn(address, label, is_mine, purpose, status); }));
529529
}
530530
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
531531
{
532532
return MakeHandler(m_wallet->NotifyTransactionChanged.connect(
533-
[fn](CWallet*, const uint256& txid, ChangeType status) { fn(txid, status); }));
533+
[fn](const uint256& txid, ChangeType status) { fn(txid, status); }));
534534
}
535535
std::unique_ptr<Handler> handleInstantLockReceived(InstantLockReceivedFn fn) override
536536
{

src/wallet/wallet.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const CWalletTx::Confirmatio
918918
wtx.MarkDirty();
919919

920920
// Notify UI of new or updated transaction
921-
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
921+
NotifyTransactionChanged(hash, fInsertedNew ? CT_NEW : CT_UPDATED);
922922

923923
#if HAVE_SYSTEM
924924
// notify an external script when a wallet transaction comes in or is updated
@@ -1101,7 +1101,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11011101
wtx.setAbandoned();
11021102
wtx.MarkDirty();
11031103
batch.WriteTx(wtx);
1104-
NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED);
1104+
NotifyTransactionChanged(wtx.GetHash(), CT_UPDATED);
11051105
// Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too
11061106
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0));
11071107
while (iter != mapTxSpends.end() && iter->first.hash == now) {
@@ -3804,7 +3804,7 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
38043804

38053805
CWalletTx &coin = mapWallet.at(txin.prevout.hash);
38063806
coin.MarkDirty();
3807-
NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED);
3807+
NotifyTransactionChanged(txin.prevout.hash, CT_UPDATED);
38083808
updated_hahes.insert(txin.prevout.hash);
38093809
}
38103810
// Get the inserted-CWalletTx from mapWallet so that the
@@ -3901,7 +3901,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
39013901
for (const auto& txin : it->second.tx->vin)
39023902
mapTxSpends.erase(txin.prevout);
39033903
mapWallet.erase(it);
3904-
NotifyTransactionChanged(this, hash, CT_DELETED);
3904+
NotifyTransactionChanged(hash, CT_DELETED);
39053905
}
39063906

39073907
if (nZapSelectTxRet == DBErrors::NEED_REWRITE)
@@ -3936,8 +3936,8 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
39363936
m_address_book[address].purpose = strPurpose;
39373937
is_mine = IsMine(address) != ISMINE_NO;
39383938
}
3939-
NotifyAddressBookChanged(this, address, strName, is_mine,
3940-
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
3939+
NotifyAddressBookChanged(address, strName, is_mine,
3940+
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW));
39413941
if (!strPurpose.empty() && !batch.WritePurpose(EncodeDestination(address), strPurpose))
39423942
return false;
39433943
return batch.WriteName(EncodeDestination(address), strName);
@@ -3972,7 +3972,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
39723972
is_mine = IsMine(address) != ISMINE_NO;
39733973
}
39743974

3975-
NotifyAddressBookChanged(this, address, "", is_mine, "", CT_DELETED);
3975+
NotifyAddressBookChanged(address, "", is_mine, "", CT_DELETED);
39763976

39773977
batch.ErasePurpose(EncodeDestination(address));
39783978
return batch.EraseName(EncodeDestination(address));
@@ -5156,7 +5156,7 @@ void CWallet::notifyTransactionLock(const CTransactionRef &tx, const std::shared
51565156
uint256 txHash = tx->GetHash();
51575157
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txHash);
51585158
if (mi != mapWallet.end()){
5159-
NotifyTransactionChanged(this, txHash, CT_UPDATED);
5159+
NotifyTransactionChanged(txHash, CT_UPDATED);
51605160
NotifyISLockReceived();
51615161
#if HAVE_SYSTEM
51625162
// notify an external script

src/wallet/wallet.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,19 +1223,18 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
12231223

12241224
/**
12251225
* Address book entry changed.
1226-
* @note called with lock cs_wallet held.
1226+
* @note called without lock cs_wallet held.
12271227
*/
1228-
boost::signals2::signal<void (CWallet *wallet, const CTxDestination
1229-
&address, const std::string &label, bool isMine,
1230-
const std::string &purpose,
1231-
ChangeType status)> NotifyAddressBookChanged;
1228+
boost::signals2::signal<void(const CTxDestination& address,
1229+
const std::string& label, bool isMine,
1230+
const std::string& purpose, ChangeType status)>
1231+
NotifyAddressBookChanged;
12321232

12331233
/**
12341234
* Wallet transaction added, removed or updated.
12351235
* @note called with lock cs_wallet held.
12361236
*/
1237-
boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx,
1238-
ChangeType status)> NotifyTransactionChanged;
1237+
boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
12391238

12401239
/** Show progress e.g. for rescan */
12411240
boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;

0 commit comments

Comments
 (0)