Skip to content

Commit 10379f0

Browse files
committed
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-
1 parent c7c64db commit 10379f0

File tree

6 files changed

+34
-34
lines changed

6 files changed

+34
-34
lines changed

src/bench/coin_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void CoinSelection(benchmark::Bench& bench)
5858
// Create coins
5959
std::vector<COutput> coins;
6060
for (const auto& wtx : wtxs) {
61-
coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* nDepthIn */, true /* spendable */, true /* solvable */, true /* safe */);
61+
coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* depth */, true /* spendable */, true /* solvable */, true /* safe */);
6262
}
6363

6464
const CoinEligibilityFilter filter_standard(1, 6, 0);

src/wallet/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class WalletImpl : public Wallet
420420
auto& group = result[entry.first];
421421
for (const auto& coin : entry.second) {
422422
group.emplace_back(COutPoint(coin.tx->GetHash(), coin.i),
423-
MakeWalletTxOut(*m_wallet, *coin.tx, coin.i, coin.nDepth));
423+
MakeWalletTxOut(*m_wallet, *coin.tx, coin.i, coin.depth));
424424
}
425425
}
426426
return result;

src/wallet/rpc/coins.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ RPCHelpMan listunspent()
703703

704704
entry.pushKV("scriptPubKey", HexStr(scriptPubKey));
705705
entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue));
706-
entry.pushKV("confirmations", out.nDepth);
707-
if (!out.nDepth) {
706+
entry.pushKV("confirmations", out.depth);
707+
if (!out.depth) {
708708
size_t ancestor_count, descendant_count, ancestor_size;
709709
CAmount ancestor_fees;
710710
pwallet->chain().getTransactionAncestry(out.tx->GetHash(), ancestor_count, descendant_count, &ancestor_size, &ancestor_fees);
@@ -714,17 +714,17 @@ RPCHelpMan listunspent()
714714
entry.pushKV("ancestorfees", uint64_t(ancestor_fees));
715715
}
716716
}
717-
entry.pushKV("spendable", out.fSpendable);
718-
entry.pushKV("solvable", out.fSolvable);
719-
if (out.fSolvable) {
717+
entry.pushKV("spendable", out.spendable);
718+
entry.pushKV("solvable", out.solvable);
719+
if (out.solvable) {
720720
std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
721721
if (provider) {
722722
auto descriptor = InferDescriptor(scriptPubKey, *provider);
723723
entry.pushKV("desc", descriptor->ToString());
724724
}
725725
}
726726
if (avoid_reuse) entry.pushKV("reused", reused);
727-
entry.pushKV("safe", out.fSafe);
727+
entry.pushKV("safe", out.safe);
728728
results.push_back(entry);
729729
}
730730

src/wallet/spend.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out
3131

3232
std::string COutput::ToString() const
3333
{
34-
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->tx->vout[i].nValue));
34+
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, depth, FormatMoney(tx->tx->vout[i].nValue));
3535
}
3636

3737
int CalculateMaximumSignedInputSize(const CTxOut& txout, const SigningProvider* provider, bool use_max_sig)
@@ -218,7 +218,7 @@ CAmount GetAvailableBalance(const CWallet& wallet, const CCoinControl* coinContr
218218
std::vector<COutput> vCoins;
219219
AvailableCoins(wallet, vCoins, coinControl);
220220
for (const COutput& out : vCoins) {
221-
if (out.fSpendable) {
221+
if (out.spendable) {
222222
balance += out.tx->tx->vout[out.i].nValue;
223223
}
224224
}
@@ -254,7 +254,7 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
254254

255255
for (const COutput& coin : availableCoins) {
256256
CTxDestination address;
257-
if ((coin.fSpendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.fSolvable)) &&
257+
if ((coin.spendable || (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && coin.solvable)) &&
258258
ExtractDestination(FindNonChangeParentOutput(wallet, *coin.tx->tx, coin.i).scriptPubKey, address)) {
259259
result[address].emplace_back(std::move(coin));
260260
}
@@ -292,15 +292,15 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
292292
// Allowing partial spends means no grouping. Each COutput gets its own OutputGroup.
293293
for (const COutput& output : outputs) {
294294
// Skip outputs we cannot spend
295-
if (!output.fSpendable) continue;
295+
if (!output.spendable) continue;
296296

297297
size_t ancestors, descendants;
298298
wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants);
299299
CInputCoin input_coin = output.GetInputCoin();
300300

301301
// Make an OutputGroup containing just this output
302302
OutputGroup group{coin_sel_params};
303-
group.Insert(input_coin, output.nDepth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
303+
group.Insert(input_coin, output.depth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
304304

305305
// Check the OutputGroup's eligibility. Only add the eligible ones.
306306
if (positive_only && group.GetSelectionAmount() <= 0) continue;
@@ -318,7 +318,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
318318
std::map<CScript, std::vector<OutputGroup>> spk_to_groups_map;
319319
for (const auto& output : outputs) {
320320
// Skip outputs we cannot spend
321-
if (!output.fSpendable) continue;
321+
if (!output.spendable) continue;
322322

323323
size_t ancestors, descendants;
324324
wallet.chain().getTransactionAncestry(output.tx->GetHash(), ancestors, descendants);
@@ -345,7 +345,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
345345
}
346346

347347
// Add the input_coin to group
348-
group->Insert(input_coin, output.nDepth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
348+
group->Insert(input_coin, output.depth, CachedTxIsFromMe(wallet, *output.tx, ISMINE_ALL), ancestors, descendants, positive_only);
349349
}
350350

351351
// 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
421421
if (coin_control.HasSelected() && !coin_control.fAllowOtherInputs)
422422
{
423423
for (const COutput& out : vCoins) {
424-
if (!out.fSpendable) continue;
424+
if (!out.spendable) continue;
425425
/* 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.
426426
* positive_only is set to false because we want to include all preset inputs, even if they are dust.
427427
*/

src/wallet/spend.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ class COutput
2727
* If > 0: the tx is on chain and has this many confirmations.
2828
* If = 0: the tx is waiting confirmation.
2929
* If < 0: a conflicting tx is on chain and has this many confirmations. */
30-
int nDepth;
30+
int depth;
3131

3232
/** Pre-computed estimated size of this output as a fully-signed input in a transaction. Can be -1 if it could not be calculated */
33-
int nInputBytes;
33+
int input_bytes;
3434

3535
/** Whether we have the private keys to spend this output */
36-
bool fSpendable;
36+
bool spendable;
3737

3838
/** Whether we know how to spend this output, ignoring the lack of keys */
39-
bool fSolvable;
39+
bool solvable;
4040

4141
/** 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 */
4242
bool use_max_sig;
@@ -46,30 +46,30 @@ class COutput
4646
* from outside keys and unconfirmed replacement transactions are considered
4747
* unsafe and will not be used to fund new spending transactions.
4848
*/
49-
bool fSafe;
49+
bool safe;
5050

51-
COutput(const CWallet& wallet, const CWalletTx& wtx, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in = false)
51+
COutput(const CWallet& wallet, const CWalletTx& wtx, int iIn, int depth, bool spendable, bool solvable, bool safe, bool use_max_sig_in = false)
5252
: tx(&wtx),
5353
i(iIn),
54-
nDepth(nDepthIn),
55-
nInputBytes(-1),
56-
fSpendable(fSpendableIn),
57-
fSolvable(fSolvableIn),
54+
depth(depth),
55+
input_bytes(-1),
56+
spendable(spendable),
57+
solvable(solvable),
5858
use_max_sig(use_max_sig_in),
59-
fSafe(fSafeIn)
59+
safe(safe)
6060
{
61-
// If known and signable by the given wallet, compute nInputBytes
61+
// If known and signable by the given wallet, compute input_bytes
6262
// Failure will keep this value -1
63-
if (fSpendable) {
64-
nInputBytes = GetTxSpendSize(wallet, wtx, i, use_max_sig);
63+
if (spendable) {
64+
input_bytes = GetTxSpendSize(wallet, wtx, i, use_max_sig);
6565
}
6666
}
6767

6868
std::string ToString() const;
6969

7070
inline CInputCoin GetInputCoin() const
7171
{
72-
return CInputCoin(tx->tx, i, nInputBytes);
72+
return CInputCoin(tx->tx, i, input_bytes);
7373
}
7474
};
7575

src/wallet/test/coinselector_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ inline std::vector<OutputGroup>& GroupCoins(const std::vector<COutput>& coins)
157157
static_groups.clear();
158158
for (auto& coin : coins) {
159159
static_groups.emplace_back();
160-
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);
160+
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);
161161
}
162162
return static_groups;
163163
}
@@ -315,13 +315,13 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
315315
std::vector<COutput> coins;
316316

317317
add_coin(coins, *wallet, 1);
318-
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
318+
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
319319
BOOST_CHECK(!SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change));
320320

321321
// Test fees subtracted from output:
322322
coins.clear();
323323
add_coin(coins, *wallet, 1 * CENT);
324-
coins.at(0).nInputBytes = 40;
324+
coins.at(0).input_bytes = 40;
325325
coin_selection_params_bnb.m_subtract_fee_outputs = true;
326326
const auto result9 = SelectCoinsBnB(GroupCoins(coins), 1 * CENT, coin_selection_params_bnb.m_cost_of_change);
327327
BOOST_CHECK(result9);

0 commit comments

Comments
 (0)