scripted-diff: wallet: Rename pcoin to wtx

-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/const CWalletTx ?\* ?pcoin = &/const CWalletTx\& wtx = /g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin->/wtx./g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin\>/\&wtx/g' src/wallet/wallet.cpp
-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke 2019-03-10 17:29:54 -04:00
parent fae5f874d5
commit faa3a246e8
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -2180,9 +2180,9 @@ CAmount CWallet::GetBalance(const isminefilter& filter, const int min_depth) con
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
if (pcoin->IsTrusted(*locked_chain) && pcoin->GetDepthInMainChain(*locked_chain) >= min_depth) { if (wtx.IsTrusted(*locked_chain) && wtx.GetDepthInMainChain(*locked_chain) >= min_depth) {
nTotal += pcoin->GetAvailableCredit(*locked_chain, true, filter); nTotal += wtx.GetAvailableCredit(*locked_chain, true, filter);
} }
} }
} }
@ -2198,9 +2198,9 @@ CAmount CWallet::GetUnconfirmedBalance() const
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
if (!pcoin->IsTrusted(*locked_chain) && pcoin->GetDepthInMainChain(*locked_chain) == 0 && pcoin->InMempool()) if (!wtx.IsTrusted(*locked_chain) && wtx.GetDepthInMainChain(*locked_chain) == 0 && wtx.InMempool())
nTotal += pcoin->GetAvailableCredit(*locked_chain); nTotal += wtx.GetAvailableCredit(*locked_chain);
} }
} }
return nTotal; return nTotal;
@ -2214,8 +2214,8 @@ CAmount CWallet::GetImmatureBalance() const
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
nTotal += pcoin->GetImmatureCredit(*locked_chain); nTotal += wtx.GetImmatureCredit(*locked_chain);
} }
} }
return nTotal; return nTotal;
@ -2229,9 +2229,9 @@ CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
if (!pcoin->IsTrusted(*locked_chain) && pcoin->GetDepthInMainChain(*locked_chain) == 0 && pcoin->InMempool()) if (!wtx.IsTrusted(*locked_chain) && wtx.GetDepthInMainChain(*locked_chain) == 0 && wtx.InMempool())
nTotal += pcoin->GetAvailableCredit(*locked_chain, true, ISMINE_WATCH_ONLY); nTotal += wtx.GetAvailableCredit(*locked_chain, true, ISMINE_WATCH_ONLY);
} }
} }
return nTotal; return nTotal;
@ -2245,8 +2245,8 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
nTotal += pcoin->GetImmatureWatchOnlyCredit(*locked_chain); nTotal += wtx.GetImmatureWatchOnlyCredit(*locked_chain);
} }
} }
return nTotal; return nTotal;
@ -2319,25 +2319,25 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
for (const auto& entry : mapWallet) for (const auto& entry : mapWallet)
{ {
const uint256& wtxid = entry.first; const uint256& wtxid = entry.first;
const CWalletTx* pcoin = &entry.second; const CWalletTx& wtx = entry.second;
if (!locked_chain.checkFinalTx(*pcoin->tx)) { if (!locked_chain.checkFinalTx(*wtx.tx)) {
continue; continue;
} }
if (pcoin->IsImmatureCoinBase(locked_chain)) if (wtx.IsImmatureCoinBase(locked_chain))
continue; continue;
int nDepth = pcoin->GetDepthInMainChain(locked_chain); int nDepth = wtx.GetDepthInMainChain(locked_chain);
if (nDepth < 0) if (nDepth < 0)
continue; continue;
// We should not consider coins which aren't at least in our mempool // We should not consider coins which aren't at least in our mempool
// It's possible for these to be conflicted via ancestors which we may never be able to detect // It's possible for these to be conflicted via ancestors which we may never be able to detect
if (nDepth == 0 && !pcoin->InMempool()) if (nDepth == 0 && !wtx.InMempool())
continue; continue;
bool safeTx = pcoin->IsTrusted(locked_chain); bool safeTx = wtx.IsTrusted(locked_chain);
// We should not consider coins from transactions that are replacing // We should not consider coins from transactions that are replacing
// other transactions. // other transactions.
@ -2354,7 +2354,7 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
// be a 1-block reorg away from the chain where transactions A and C // be a 1-block reorg away from the chain where transactions A and C
// were accepted to another chain where B, B', and C were all // were accepted to another chain where B, B', and C were all
// accepted. // accepted.
if (nDepth == 0 && pcoin->mapValue.count("replaces_txid")) { if (nDepth == 0 && wtx.mapValue.count("replaces_txid")) {
safeTx = false; safeTx = false;
} }
@ -2366,7 +2366,7 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
// intending to replace A', but potentially resulting in a scenario // intending to replace A', but potentially resulting in a scenario
// where A, A', and D could all be accepted (instead of just B and // where A, A', and D could all be accepted (instead of just B and
// D, or just A and A' like the user would want). // D, or just A and A' like the user would want).
if (nDepth == 0 && pcoin->mapValue.count("replaced_by_txid")) { if (nDepth == 0 && wtx.mapValue.count("replaced_by_txid")) {
safeTx = false; safeTx = false;
} }
@ -2377,8 +2377,8 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
if (nDepth < nMinDepth || nDepth > nMaxDepth) if (nDepth < nMinDepth || nDepth > nMaxDepth)
continue; continue;
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++) { for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
if (pcoin->tx->vout[i].nValue < nMinimumAmount || pcoin->tx->vout[i].nValue > nMaximumAmount) if (wtx.tx->vout[i].nValue < nMinimumAmount || wtx.tx->vout[i].nValue > nMaximumAmount)
continue; continue;
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(entry.first, i))) if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(entry.first, i)))
@ -2390,20 +2390,20 @@ void CWallet::AvailableCoins(interfaces::Chain::Lock& locked_chain, std::vector<
if (IsSpent(locked_chain, wtxid, i)) if (IsSpent(locked_chain, wtxid, i))
continue; continue;
isminetype mine = IsMine(pcoin->tx->vout[i]); isminetype mine = IsMine(wtx.tx->vout[i]);
if (mine == ISMINE_NO) { if (mine == ISMINE_NO) {
continue; continue;
} }
bool solvable = IsSolvable(*this, pcoin->tx->vout[i].scriptPubKey); bool solvable = IsSolvable(*this, wtx.tx->vout[i].scriptPubKey);
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable)); bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
vCoins.push_back(COutput(pcoin, i, nDepth, spendable, solvable, safeTx, (coinControl && coinControl->fAllowWatchOnly))); vCoins.push_back(COutput(&wtx, i, nDepth, spendable, solvable, safeTx, (coinControl && coinControl->fAllowWatchOnly)));
// Checks the sum amount of all UTXO's. // Checks the sum amount of all UTXO's.
if (nMinimumSumAmount != MAX_MONEY) { if (nMinimumSumAmount != MAX_MONEY) {
nTotal += pcoin->tx->vout[i].nValue; nTotal += wtx.tx->vout[i].nValue;
if (nTotal >= nMinimumSumAmount) { if (nTotal >= nMinimumSumAmount) {
return; return;
@ -2562,13 +2562,13 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
if (it != mapWallet.end()) if (it != mapWallet.end())
{ {
const CWalletTx* pcoin = &it->second; const CWalletTx& wtx = it->second;
// Clearly invalid input, fail // Clearly invalid input, fail
if (pcoin->tx->vout.size() <= outpoint.n) if (wtx.tx->vout.size() <= outpoint.n)
return false; return false;
// Just to calculate the marginal byte size // Just to calculate the marginal byte size
nValueFromPresetInputs += pcoin->tx->vout[outpoint.n].nValue; nValueFromPresetInputs += wtx.tx->vout[outpoint.n].nValue;
setPresetCoins.insert(CInputCoin(pcoin->tx, outpoint.n)); setPresetCoins.insert(CInputCoin(wtx.tx, outpoint.n));
} else } else
return false; // TODO: Allow non-wallet inputs return false; // TODO: Allow non-wallet inputs
} }
@ -3606,27 +3606,27 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances(interfaces::Chain:
LOCK(cs_wallet); LOCK(cs_wallet);
for (const auto& walletEntry : mapWallet) for (const auto& walletEntry : mapWallet)
{ {
const CWalletTx *pcoin = &walletEntry.second; const CWalletTx& wtx = walletEntry.second;
if (!pcoin->IsTrusted(locked_chain)) if (!wtx.IsTrusted(locked_chain))
continue; continue;
if (pcoin->IsImmatureCoinBase(locked_chain)) if (wtx.IsImmatureCoinBase(locked_chain))
continue; continue;
int nDepth = pcoin->GetDepthInMainChain(locked_chain); int nDepth = wtx.GetDepthInMainChain(locked_chain);
if (nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? 0 : 1)) if (nDepth < (wtx.IsFromMe(ISMINE_ALL) ? 0 : 1))
continue; continue;
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++) for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{ {
CTxDestination addr; CTxDestination addr;
if (!IsMine(pcoin->tx->vout[i])) if (!IsMine(wtx.tx->vout[i]))
continue; continue;
if(!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, addr)) if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
continue; continue;
CAmount n = IsSpent(locked_chain, walletEntry.first, i) ? 0 : pcoin->tx->vout[i].nValue; CAmount n = IsSpent(locked_chain, walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue;
if (!balances.count(addr)) if (!balances.count(addr))
balances[addr] = 0; balances[addr] = 0;
@ -3646,13 +3646,13 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
for (const auto& walletEntry : mapWallet) for (const auto& walletEntry : mapWallet)
{ {
const CWalletTx *pcoin = &walletEntry.second; const CWalletTx& wtx = walletEntry.second;
if (pcoin->tx->vin.size() > 0) if (wtx.tx->vin.size() > 0)
{ {
bool any_mine = false; bool any_mine = false;
// group all input addresses with each other // group all input addresses with each other
for (const CTxIn& txin : pcoin->tx->vin) for (const CTxIn& txin : wtx.tx->vin)
{ {
CTxDestination address; CTxDestination address;
if(!IsMine(txin)) /* If this input isn't mine, ignore it */ if(!IsMine(txin)) /* If this input isn't mine, ignore it */
@ -3666,7 +3666,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
// group change with input addresses // group change with input addresses
if (any_mine) if (any_mine)
{ {
for (const CTxOut& txout : pcoin->tx->vout) for (const CTxOut& txout : wtx.tx->vout)
if (IsChange(txout)) if (IsChange(txout))
{ {
CTxDestination txoutAddr; CTxDestination txoutAddr;
@ -3683,7 +3683,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
} }
// group lone addrs by themselves // group lone addrs by themselves
for (const auto& txout : pcoin->tx->vout) for (const auto& txout : wtx.tx->vout)
if (IsMine(txout)) if (IsMine(txout))
{ {
CTxDestination address; CTxDestination address;