scripted-diff: Rename COutput member variables

Update the member variables to match the new style

-BEGIN VERIFY SCRIPT-
sed -i 's/fSpendableIn/spendable/' $(git grep -l "fSpendableIn")
sed -i 's/fSpendable/spendable/' $(git grep -l "fSpendable")
sed -i 's/fSolvableIn/solvable/' $(git grep -l "fSolvableIn")
sed -i 's/fSolvable/solvable/' $(git grep -l "fSolvable")
sed -i 's/fSafeIn/safe/' $(git grep -l "fSafeIn")
sed -i 's/fSafe/safe/' $(git grep -l "fSafe")
sed -i 's/nInputBytes/input_bytes/' $(git grep -l "nInputBytes")
sed -i 's/nDepthIn/depth/' $(git grep -l "nDepthIn" src/wallet src/bench)
sed -i 's/nDepth/depth/' src/wallet/spend.h
sed -i 's/\.nDepth/.depth/' $(git grep -l "\.nDepth" src/wallet/)
sed -i 's/nDepth, FormatMoney/depth, FormatMoney/' src/wallet/spend.cpp
-END VERIFY SCRIPT-
pull/24091/head
Andrew Chow 3 years ago
parent c7c64db41e
commit 10379f007f

@ -58,7 +58,7 @@ static void CoinSelection(benchmark::Bench& bench)
// Create coins // Create coins
std::vector<COutput> coins; std::vector<COutput> coins;
for (const auto& wtx : wtxs) { for (const auto& wtx : wtxs) {
coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* nDepthIn */, true /* spendable */, true /* solvable */, true /* safe */); coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* depth */, true /* spendable */, true /* solvable */, true /* safe */);
} }
const CoinEligibilityFilter filter_standard(1, 6, 0); const CoinEligibilityFilter filter_standard(1, 6, 0);

@ -420,7 +420,7 @@ public:
auto& group = result[entry.first]; auto& group = result[entry.first];
for (const auto& coin : entry.second) { for (const auto& coin : entry.second) {
group.emplace_back(COutPoint(coin.tx->GetHash(), coin.i), group.emplace_back(COutPoint(coin.tx->GetHash(), coin.i),
MakeWalletTxOut(*m_wallet, *coin.tx, coin.i, coin.nDepth)); MakeWalletTxOut(*m_wallet, *coin.tx, coin.i, coin.depth));
} }
} }
return result; return result;

@ -703,8 +703,8 @@ RPCHelpMan listunspent()
entry.pushKV("scriptPubKey", HexStr(scriptPubKey)); entry.pushKV("scriptPubKey", HexStr(scriptPubKey));
entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)); entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue));
entry.pushKV("confirmations", out.nDepth); entry.pushKV("confirmations", out.depth);
if (!out.nDepth) { if (!out.depth) {
size_t ancestor_count, descendant_count, ancestor_size; size_t ancestor_count, descendant_count, ancestor_size;
CAmount ancestor_fees; CAmount ancestor_fees;
pwallet->chain().getTransactionAncestry(out.tx->GetHash(), ancestor_count, descendant_count, &ancestor_size, &ancestor_fees); pwallet->chain().getTransactionAncestry(out.tx->GetHash(), ancestor_count, descendant_count, &ancestor_size, &ancestor_fees);
@ -714,9 +714,9 @@ RPCHelpMan listunspent()
entry.pushKV("ancestorfees", uint64_t(ancestor_fees)); entry.pushKV("ancestorfees", uint64_t(ancestor_fees));
} }
} }
entry.pushKV("spendable", out.fSpendable); entry.pushKV("spendable", out.spendable);
entry.pushKV("solvable", out.fSolvable); entry.pushKV("solvable", out.solvable);
if (out.fSolvable) { if (out.solvable) {
std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey); std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
if (provider) { if (provider) {
auto descriptor = InferDescriptor(scriptPubKey, *provider); auto descriptor = InferDescriptor(scriptPubKey, *provider);
@ -724,7 +724,7 @@ RPCHelpMan listunspent()
} }
} }
if (avoid_reuse) entry.pushKV("reused", reused); if (avoid_reuse) entry.pushKV("reused", reused);
entry.pushKV("safe", out.fSafe); entry.pushKV("safe", out.safe);
results.push_back(entry); results.push_back(entry);
} }

@ -31,7 +31,7 @@ int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out
std::string COutput::ToString() const std::string COutput::ToString() const
{ {
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->tx->vout[i].nValue)); return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, depth, FormatMoney(tx->tx->vout[i].nValue));
} }
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig) int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
@ -218,7 +218,7 @@ CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinContr
std::vector<COutput> vCoins; std::vector<COutput> vCoins;
AvailableCoins(wallet, vCoins, coinControl); AvailableCoins(wallet, vCoins, coinControl);
for (const COutput& out : vCoins) { for (const COutput& out : vCoins) {
if (out.fSpendable) { if (out.spendable) {
balance += out.tx->tx->vout[out.i].nValue; balance += out.tx->tx->vout[out.i].nValue;
} }
} }
@ -254,7 +254,7 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
for (const COutput& coin : availableCoins) { for (const COutput& coin : availableCoins) {
CTxDestination address; CTxDestination address;
if ((coin.fSpendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.fSolvable)) && if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable)) &&
ExtractDestination(FindNonChangeParentOutput(wallet, *coin.tx->tx, coin.i).scriptPubKey, address)) { ExtractDestination(FindNonChangeParentOutput(wallet, *coin.tx->tx, coin.i).scriptPubKey, address)) {
result[address].emplace_back(std::move(coin)); result[address].emplace_back(std::move(coin));
} }
@ -292,7 +292,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
// Allowing partial spends means no grouping. Each COutput gets its own OutputGroup. // Allowing partial spends means no grouping. Each COutput gets its own OutputGroup.
for (const COutput& output : outputs) { for (const COutput& output : outputs) {
// Skip outputs we cannot spend // Skip outputs we cannot spend
if (!output.fSpendable) continue; if (!output.spendable) continue;
size_t ancestors, descendants; size_t ancestors, descendants;
wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants); wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants);
@ -300,7 +300,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
// Make an OutputGroup containing just this output // Make an OutputGroup containing just this output
OutputGroup group{coin_sel_params}; OutputGroup group{coin_sel_params};
group.Insert(input_coin, output.nDepth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only); group.Insert(input_coin, output.depth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
// Check the OutputGroup's eligibility. Only add the eligible ones. // Check the OutputGroup's eligibility. Only add the eligible ones.
if (positive_only && group.GetSelectionAmount() <= 0) continue; if (positive_only && group.GetSelectionAmount() <= 0) continue;
@ -318,7 +318,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
std::map<CScript, std::vector<OutputGroup>> spk_to_groups_map; std::map<CScript, std::vector<OutputGroup>> spk_to_groups_map;
for (const auto& output : outputs) { for (const auto& output : outputs) {
// Skip outputs we cannot spend // Skip outputs we cannot spend
if (!output.fSpendable) continue; if (!output.spendable) continue;
size_t ancestors, descendants; size_t ancestors, descendants;
wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants); wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants);
@ -345,7 +345,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
} }
// Add the input_coin to group // Add the input_coin to group
group->Insert(input_coin, output.nDepth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only); group->Insert(input_coin, output.depth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
} }
// Now we go through the entire map and pull out the OutputGroups // Now we go through the entire map and pull out the OutputGroups
@ -421,7 +421,7 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
if (coin_control.HasSelected() && !coin_control.fAllowOtherInputs) if (coin_control.HasSelected() && !coin_control.fAllowOtherInputs)
{ {
for (const COutput& out : vCoins) { for (const COutput& out : vCoins) {
if (!out.fSpendable) continue; if (!out.spendable) continue;
/* Set depth, from_me, ancestors, and descendants to 0 or false as these don't matter for preset inputs as no actual selection is being done. /* Set depth, from_me, ancestors, and descendants to 0 or false as these don't matter for preset inputs as no actual selection is being done.
* positive_only is set to false because we want to include all preset inputs, even if they are dust. * positive_only is set to false because we want to include all preset inputs, even if they are dust.
*/ */

@ -27,16 +27,16 @@ public:
* If > 0: the tx is on chain and has this many confirmations. * If > 0: the tx is on chain and has this many confirmations.
* If = 0: the tx is waiting confirmation. * If = 0: the tx is waiting confirmation.
* If < 0: a conflicting tx is on chain and has this many confirmations. */ * If < 0: a conflicting tx is on chain and has this many confirmations. */
int nDepth; int depth;
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */ /** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
int nInputBytes; int input_bytes;
/** Whether we have the private keys to spend this output */ /** Whether we have the private keys to spend this output */
bool fSpendable; bool spendable;
/** Whether we know how to spend this output, ignoring the lack of keys */ /** Whether we know how to spend this output, ignoring the lack of keys */
bool fSolvable; bool solvable;
/** Whether to use the maximum sized, 72 byte signature when calculating the size of the input spend. This should only be set when watch-only outputs are allowed */ /** Whether to use the maximum sized, 72 byte signature when calculating the size of the input spend. This should only be set when watch-only outputs are allowed */
bool use_max_sig; bool use_max_sig;
@ -46,22 +46,22 @@ public:
* from outside keys and unconfirmed replacement transactions are considered * from outside keys and unconfirmed replacement transactions are considered
* unsafe and will not be used to fund new spending transactions. * unsafe and will not be used to fund new spending transactions.
*/ */
bool fSafe; bool safe;
COutput(const CWallet& wallet, const CWalletTx& wtx, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false) COutput(const CWallet& wallet, const CWalletTx& wtx, int iIn, int depth, bool spendable, bool solvable, bool safe, bool use_max_sig_in = false)
: tx(&wtx), : tx(&wtx),
i(iIn), i(iIn),
nDepth(nDepthIn), depth(depth),
nInputBytes(-1), input_bytes(-1),
fSpendable(fSpendableIn), spendable(spendable),
fSolvable(fSolvableIn), solvable(solvable),
use_max_sig(use_max_sig_in), use_max_sig(use_max_sig_in),
fSafe(fSafeIn) safe(safe)
{ {
// If known and signable by the given wallet, compute nInputBytes // If known and signable by the given wallet, compute input_bytes
// Failure will keep this value -1 // Failure will keep this value -1
if (fSpendable) { if (spendable) {
nInputBytes = GetTxSpendSize(wallet, wtx, i, use_max_sig); input_bytes = GetTxSpendSize(wallet, wtx, i, use_max_sig);
} }
} }
@ -69,7 +69,7 @@ public:
inline CInputCoin GetInputCoin() const inline CInputCoin GetInputCoin() const
{ {
return CInputCoin(tx->tx, i, nInputBytes); return CInputCoin(tx->tx, i, input_bytes);
} }
}; };

@ -157,7 +157,7 @@ inline std::vector<OutputGroup>& GroupCoins(const std::vector<COutput>& coins)
static_groups.clear(); static_groups.clear();
for (auto& coin : coins) { for (auto& coin : coins) {
static_groups.emplace_back(); static_groups.emplace_back();
static_groups.back().Insert(coin.GetInputCoin(), coin.nDepth, coin.tx->m_amounts[CWalletTx::DEBIT].m_cached[ISMINE_SPENDABLE] && coin.tx->m_amounts[CWalletTx::DEBIT].m_value[ISMINE_SPENDABLE] == 1 /* HACK: we can't figure out the is_me flag so we use the conditions defined above; perhaps set safe to false for !fIsFromMe in add_coin() */, 0, 0, false); static_groups.back().Insert(coin.GetInputCoin(), coin.depth, coin.tx->m_amounts[CWalletTx::DEBIT].m_cached[ISMINE_SPENDABLE] && coin.tx->m_amounts[CWalletTx::DEBIT].m_value[ISMINE_SPENDABLE] == 1 /* HACK: we can't figure out the is_me flag so we use the conditions defined above; perhaps set safe to false for !fIsFromMe in add_coin() */, 0, 0, false);
} }
return static_groups; return static_groups;
} }
@ -315,13 +315,13 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
std::vector<COutput> coins; std::vector<COutput> coins;
add_coin(coins, *wallet, 1); add_coin(coins, *wallet, 1);
coins.at(0).nInputBytes = 40; // Make sure that it has a negative effective value. The next check should assert if this somehow got through. Otherwise it will fail coins.at(0).input_bytes = 40; // Make sure that it has a negative effective value. The next check should assert if this somehow got through. Otherwise it will fail
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change)); BOOST_CHECK(!SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change));
// Test fees subtracted from output: // Test fees subtracted from output:
coins.clear(); coins.clear();
add_coin(coins, *wallet, 1 * CENT); add_coin(coins, *wallet, 1 * CENT);
coins.at(0).nInputBytes = 40; coins.at(0).input_bytes = 40;
coin_selection_params_bnb.m_subtract_fee_outputs = true; coin_selection_params_bnb.m_subtract_fee_outputs = true;
const auto result9 = SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change); const auto result9 = SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change);
BOOST_CHECK(result9); BOOST_CHECK(result9);

Loading…
Cancel
Save