mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #18193: scripted-diff: Wallet: Rename incorrectly named *UsedDestination
bca8665d0895c450e552c357a036d9e9579e3678 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 bca8665d0895c450e552c357a036d9e9579e3678 -- patch looks correct and rationale makes sense
instagibbs:
ACK bca8665d08
, much more meaningful name, thanks
kallewoof:
ACK bca8665d0895c450e552c357a036d9e9579e3678
Tree-SHA512: ff13d9061ffa748e92eb41ba962c3ec262a43e4b6abd62408b38c6f650395d6ae5851554257d1900fb02767a88d08380d592a27210192ee9abb72d0945976686
This commit is contained in:
parent
44a47b963f
commit
352744d222
@ -3133,7 +3133,7 @@ static UniValue listunspent(const JSONRPCRequest& request)
|
|||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
|
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
|
||||||
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
||||||
bool reused = avoid_reuse && pwallet->IsUsedDestination(address);
|
bool reused = avoid_reuse && pwallet->IsSpentKey(address);
|
||||||
|
|
||||||
if (destinations.size() && (!fValidAddress || !destinations.count(address)))
|
if (destinations.size() && (!fValidAddress || !destinations.count(address)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -777,7 +777,7 @@ void CWallet::MarkDirty()
|
|||||||
fAnonymizableTallyCachedNonDenom = false;
|
fAnonymizableTallyCachedNonDenom = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::SetUsedDestinationState(const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
|
void CWallet::SetSpentKeyState(const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations)
|
||||||
{
|
{
|
||||||
const CWalletTx* srctx = GetWalletTx(hash);
|
const CWalletTx* srctx = GetWalletTx(hash);
|
||||||
if (!srctx) return;
|
if (!srctx) return;
|
||||||
@ -797,17 +797,17 @@ void CWallet::SetUsedDestinationState(const uint256& hash, unsigned int n, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::IsUsedDestination(const CTxDestination& dst) const
|
bool CWallet::IsSpentKey(const CTxDestination& dst) const
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
return IsMine(dst) && GetDestData(dst, "used", nullptr);
|
return IsMine(dst) && GetDestData(dst, "used", nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::IsUsedDestination(const uint256& hash, unsigned int n) const
|
bool CWallet::IsSpentKey(const uint256& hash, unsigned int n) const
|
||||||
{
|
{
|
||||||
CTxDestination dst;
|
CTxDestination dst;
|
||||||
const CWalletTx* srctx = GetWalletTx(hash);
|
const CWalletTx* srctx = GetWalletTx(hash);
|
||||||
return srctx && ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst) && IsUsedDestination(dst);
|
return srctx && ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst) && IsSpentKey(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
||||||
@ -824,7 +824,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
|||||||
|
|
||||||
for (const CTxIn& txin : wtxIn.tx->vin) {
|
for (const CTxIn& txin : wtxIn.tx->vin) {
|
||||||
const COutPoint& op = txin.prevout;
|
const COutPoint& op = txin.prevout;
|
||||||
SetUsedDestinationState(op.hash, op.n, true, tx_destinations);
|
SetSpentKeyState(op.hash, op.n, true, tx_destinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkDestinationsDirty(tx_destinations);
|
MarkDestinationsDirty(tx_destinations);
|
||||||
@ -2102,7 +2102,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter
|
|||||||
uint256 hashTx = GetHash();
|
uint256 hashTx = GetHash();
|
||||||
for (unsigned int i = 0; i < tx->vout.size(); i++)
|
for (unsigned int i = 0; i < tx->vout.size(); i++)
|
||||||
{
|
{
|
||||||
if (!pwallet->IsSpent(hashTx, i) && (allow_used_addresses || !pwallet->IsUsedDestination(hashTx, i)))
|
if (!pwallet->IsSpent(hashTx, i) && (allow_used_addresses || !pwallet->IsSpentKey(hashTx, i)))
|
||||||
{
|
{
|
||||||
const CTxOut &txout = tx->vout[i];
|
const CTxOut &txout = tx->vout[i];
|
||||||
nCredit += pwallet->GetCredit(txout, filter);
|
nCredit += pwallet->GetCredit(txout, filter);
|
||||||
@ -2546,7 +2546,7 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allow_used_addresses && IsUsedDestination(wtxid, i)) {
|
if (!allow_used_addresses && IsSpentKey(wtxid, i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,9 +907,9 @@ public:
|
|||||||
bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
bool IsSpent(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
// Whether this or any UTXO with the same CTxDestination has been spent.
|
// Whether this or any UTXO with the same CTxDestination has been spent.
|
||||||
bool IsUsedDestination(const CTxDestination& dst) const;
|
bool IsSpentKey(const CTxDestination& dst) const;
|
||||||
bool IsUsedDestination(const uint256& hash, unsigned int n) const;
|
bool IsSpentKey(const uint256& hash, unsigned int n) const;
|
||||||
void SetUsedDestinationState(const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations);
|
void SetSpentKeyState(const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations);
|
||||||
|
|
||||||
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
|
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user