Skip to content

Commit 225aa5d

Browse files
author
MarcoFalke
committed
Merge #18193: scripted-diff: Wallet: Rename incorrectly named *UsedDestination
bca8665 scripted-diff: Wallet: Rename incorrectly named *UsedDestination (Luke Dashjr) Pull request description: These functions are used to mark/check if a key of our own has been used to spend (and only for avoid-reuse wallets), which has nothing to do with the destination/address itself. Give them more accurate names to avoid confusion. -BEGIN VERIFY SCRIPT- sed -i -e 's/UsedDestination/SpentKey/g' $(git grep -l 'UsedDestination' ./src) -END VERIFY SCRIPT- ACKs for top commit: practicalswift: ACK bca8665 -- patch looks correct and rationale makes sense instagibbs: ACK bitcoin/bitcoin@bca8665, much more meaningful name, thanks kallewoof: ACK bca8665 Tree-SHA512: ff13d9061ffa748e92eb41ba962c3ec262a43e4b6abd62408b38c6f650395d6ae5851554257d1900fb02767a88d08380d592a27210192ee9abb72d0945976686
2 parents ab9de43 + bca8665 commit 225aa5d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ static UniValue listunspent(const JSONRPCRequest& request)
29252925
CTxDestination address;
29262926
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
29272927
bool fValidAddress = ExtractDestination(scriptPubKey, address);
2928-
bool reused = avoid_reuse && pwallet->IsUsedDestination(out.tx->GetHash(), out.i);
2928+
bool reused = avoid_reuse && pwallet->IsSpentKey(out.tx->GetHash(), out.i);
29292929

29302930
if (destinations.size() && (!fValidAddress || !destinations.count(address)))
29312931
continue;

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
714714
return success;
715715
}
716716

717-
void CWallet::SetUsedDestinationState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
717+
void CWallet::SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
718718
{
719719
AssertLockHeld(cs_wallet);
720720
const CWalletTx* srctx = GetWalletTx(hash);
@@ -734,7 +734,7 @@ void CWallet::SetUsedDestinationState(WalletBatch& batch, const uint256& hash, u
734734
}
735735
}
736736

737-
bool CWallet::IsUsedDestination(const uint256& hash, unsigned int n) const
737+
bool CWallet::IsSpentKey(const uint256& hash, unsigned int n) const
738738
{
739739
AssertLockHeld(cs_wallet);
740740
CTxDestination dst;
@@ -777,7 +777,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
777777

778778
for (const CTxIn& txin : wtxIn.tx->vin) {
779779
const COutPoint& op = txin.prevout;
780-
SetUsedDestinationState(batch, op.hash, op.n, true, tx_destinations);
780+
SetSpentKeyState(batch, op.hash, op.n, true, tx_destinations);
781781
}
782782

783783
MarkDestinationsDirty(tx_destinations);
@@ -1878,7 +1878,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter
18781878
uint256 hashTx = GetHash();
18791879
for (unsigned int i = 0; i < tx->vout.size(); i++)
18801880
{
1881-
if (!pwallet->IsSpent(hashTx, i) && (allow_used_addresses || !pwallet->IsUsedDestination(hashTx, i))) {
1881+
if (!pwallet->IsSpent(hashTx, i) && (allow_used_addresses || !pwallet->IsSpentKey(hashTx, i))) {
18821882
const CTxOut &txout = tx->vout[i];
18831883
nCredit += pwallet->GetCredit(txout, filter);
18841884
if (!MoneyRange(nCredit))
@@ -2168,7 +2168,7 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
21682168
continue;
21692169
}
21702170

2171-
if (!allow_used_addresses && IsUsedDestination(wtxid, i)) {
2171+
if (!allow_used_addresses && IsSpentKey(wtxid, i)) {
21722172
continue;
21732173
}
21742174

src/wallet/wallet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ class CWallet final : public WalletStorage, private interfaces::Chain::Notificat
817817
bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
818818

819819
// Whether this or any known UTXO with the same single key has been spent.
820-
bool IsUsedDestination(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
821-
void SetUsedDestinationState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
820+
bool IsSpentKey(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
821+
void SetSpentKeyState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
822822

823823
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
824824

0 commit comments

Comments
 (0)