Skip to content

Commit e0face9

Browse files
committed
Merge bitcoin/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
2 parents 8071ec1 + 8888cf4 commit e0face9

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
@@ -69,7 +69,7 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
6969
->findChild<QCheckBox*>("optInRBF")
7070
->setCheckState(rbf ? Qt::Checked : Qt::Unchecked);
7171
uint256 txid;
72-
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](CWallet*, const uint256& hash, ChangeType status) {
72+
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const uint256& hash, ChangeType status) {
7373
if (status == CT_NEW) txid = hash;
7474
}));
7575
ConfirmSend();

src/wallet/interfaces.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,13 @@ class WalletImpl : public Wallet
475475
std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) override
476476
{
477477
return MakeHandler(m_wallet->NotifyAddressBookChanged.connect(
478-
[fn](CWallet*, const CTxDestination& address, const std::string& label, bool is_mine,
479-
const std::string& purpose, ChangeType status) { fn(address, label, is_mine, purpose, status); }));
478+
[fn](const CTxDestination& address, const std::string& label, bool is_mine,
479+
const std::string& purpose, ChangeType status) { fn(address, label, is_mine, purpose, status); }));
480480
}
481481
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
482482
{
483483
return MakeHandler(m_wallet->NotifyTransactionChanged.connect(
484-
[fn](CWallet*, const uint256& txid, ChangeType status) { fn(txid, status); }));
484+
[fn](const uint256& txid, ChangeType status) { fn(txid, status); }));
485485
}
486486
std::unique_ptr<Handler> handleWatchOnlyChanged(WatchOnlyChangedFn fn) override
487487
{

src/wallet/wallet.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
801801
success = false;
802802
}
803803

804-
NotifyTransactionChanged(this, originalHash, CT_UPDATED);
804+
NotifyTransactionChanged(originalHash, CT_UPDATED);
805805

806806
return success;
807807
}
@@ -930,7 +930,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const CWalletTx::Confirmatio
930930
wtx.MarkDirty();
931931

932932
// Notify UI of new or updated transaction
933-
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
933+
NotifyTransactionChanged(hash, fInsertedNew ? CT_NEW : CT_UPDATED);
934934

935935
#if HAVE_SYSTEM
936936
// notify an external script when a wallet transaction comes in or is updated
@@ -1104,7 +1104,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11041104
wtx.setAbandoned();
11051105
wtx.MarkDirty();
11061106
batch.WriteTx(wtx);
1107-
NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED);
1107+
NotifyTransactionChanged(wtx.GetHash(), CT_UPDATED);
11081108
// Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too
11091109
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0));
11101110
while (iter != mapTxSpends.end() && iter->first.hash == now) {
@@ -1944,7 +1944,7 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
19441944
for (const CTxIn& txin : tx->vin) {
19451945
CWalletTx &coin = mapWallet.at(txin.prevout.hash);
19461946
coin.MarkDirty();
1947-
NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
1947+
NotifyTransactionChanged(coin.GetHash(), CT_UPDATED);
19481948
}
19491949

19501950
// Get the inserted-CWalletTx from mapWallet so that the
@@ -1999,7 +1999,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
19991999
for (const auto& txin : it->second.tx->vin)
20002000
mapTxSpends.erase(txin.prevout);
20012001
mapWallet.erase(it);
2002-
NotifyTransactionChanged(this, hash, CT_DELETED);
2002+
NotifyTransactionChanged(hash, CT_DELETED);
20032003
}
20042004

20052005
if (nZapSelectTxRet == DBErrors::NEED_REWRITE)
@@ -2033,8 +2033,8 @@ bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& add
20332033
m_address_book[address].purpose = strPurpose;
20342034
is_mine = IsMine(address) != ISMINE_NO;
20352035
}
2036-
NotifyAddressBookChanged(this, address, strName, is_mine,
2037-
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
2036+
NotifyAddressBookChanged(address, strName, is_mine,
2037+
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW));
20382038
if (!strPurpose.empty() && !batch.WritePurpose(EncodeDestination(address), strPurpose))
20392039
return false;
20402040
return batch.WriteName(EncodeDestination(address), strName);
@@ -2069,7 +2069,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
20692069
is_mine = IsMine(address) != ISMINE_NO;
20702070
}
20712071

2072-
NotifyAddressBookChanged(this, address, "", is_mine, "", CT_DELETED);
2072+
NotifyAddressBookChanged(address, "", is_mine, "", CT_DELETED);
20732073

20742074
batch.ErasePurpose(EncodeDestination(address));
20752075
return batch.EraseName(EncodeDestination(address));

src/wallet/wallet.h

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

725725
/**
726726
* Address book entry changed.
727-
* @note called with lock cs_wallet held.
727+
* @note called without lock cs_wallet held.
728728
*/
729-
boost::signals2::signal<void (CWallet *wallet, const CTxDestination
730-
&address, const std::string &label, bool isMine,
731-
const std::string &purpose,
732-
ChangeType status)> NotifyAddressBookChanged;
729+
boost::signals2::signal<void(const CTxDestination& address,
730+
const std::string& label, bool isMine,
731+
const std::string& purpose, ChangeType status)>
732+
NotifyAddressBookChanged;
733733

734734
/**
735735
* Wallet transaction added, removed or updated.
736736
* @note called with lock cs_wallet held.
737737
*/
738-
boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx,
739-
ChangeType status)> NotifyTransactionChanged;
738+
boost::signals2::signal<void(const uint256& hashTx, ChangeType status)> NotifyTransactionChanged;
740739

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

0 commit comments

Comments
 (0)