Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ BITCOIN_CORE_H = \
wallet/bip39.h \
wallet/bip39_english.h \
wallet/coincontrol.h \
wallet/coinjoin.h \
wallet/coinselection.h \
wallet/context.h \
wallet/crypter.h \
Expand Down Expand Up @@ -591,6 +592,7 @@ libbitcoin_wallet_a_SOURCES = \
coinjoin/interfaces.cpp \
coinjoin/util.cpp \
wallet/bip39.cpp \
wallet/coinjoin.cpp \
wallet/coincontrol.cpp \
wallet/context.cpp \
wallet/crypter.cpp \
Expand Down
7 changes: 4 additions & 3 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <interfaces/chain.h>
#include <node/context.h>
#include <wallet/coinselection.h>
#include <wallet/spend.h>
#include <wallet/wallet.h>

#include <set>
Expand All @@ -17,7 +18,7 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<st
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
tx.vout.resize(1);
tx.vout[0].nValue = nValue;
wtxs.push_back(std::make_unique<CWalletTx>(&wallet, MakeTransactionRef(std::move(tx))));
wtxs.push_back(std::make_unique<CWalletTx>(MakeTransactionRef(std::move(tx))));
}

// Simple benchmark for wallet coin selection. Note that it maybe be necessary
Expand All @@ -44,7 +45,7 @@ static void CoinSelection(benchmark::Bench& bench)
// Create coins
std::vector<COutput> coins;
for (const auto& wtx : wtxs) {
coins.emplace_back(wtx.get(), 0 /* iIn */, 6 * 24 /* nDepthIn */, true /* spendable */, true /* solvable */, true /* safe */);
coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* nDepthIn */, true /* spendable */, true /* solvable */, true /* safe */);
}
const CoinEligibilityFilter filter_standard(1, 6, 0);
const CoinSelectionParams coin_selection_params(/* change_output_size= */ 34,
Expand All @@ -54,7 +55,7 @@ static void CoinSelection(benchmark::Bench& bench)
bench.run([&] {
std::set<CInputCoin> setCoinsRet;
CAmount nValueRet;
bool success = wallet.AttemptSelection(1003 * COIN, filter_standard, coins, setCoinsRet, nValueRet, coin_selection_params);
bool success = AttemptSelection(wallet, 1003 * COIN, filter_standard, coins, setCoinsRet, nValueRet, coin_selection_params);
assert(success);
assert(nValueRet == 1003 * COIN);
assert(setCoinsRet.size() == 2);
Expand Down
5 changes: 3 additions & 2 deletions src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <test/util/setup_common.h>
#include <test/util/wallet.h>
#include <validationinterface.h>
#include <wallet/receive.h>
#include <wallet/wallet.h>

#include <optional>
Expand All @@ -35,11 +36,11 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
}
SyncWithValidationInterfaceQueue();

auto bal = wallet.GetBalance(); // Cache
auto bal = GetBalance(wallet); // Cache

bench.minEpochIterations(epoch_iters).run([&] {
if (set_dirty) wallet.MarkDirty();
bal = wallet.GetBalance();
bal = GetBalance(wallet);
if (add_mine) assert(bal.m_mine_trusted > 0);
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
#include <util/translation.h>
#include <version.h>
#include <wallet/coincontrol.h>
#include <wallet/coinjoin.h>
#include <wallet/fees.h>
#include <wallet/receive.h>
#include <wallet/spend.h>
#include <walletinitinterface.h>

#include <memory>
Expand Down Expand Up @@ -824,7 +827,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(ChainstateManager& chainman
return false;
}

const auto bal = m_wallet->GetBalance();
const auto bal = GetBalance(*m_wallet);

// check if there is anything left to do
CAmount nBalanceAnonymized = bal.m_anonymized;
Expand Down Expand Up @@ -1551,7 +1554,7 @@ bool CCoinJoinClientSession::CreateCollateralTransaction(CMutableTransaction& tx
CCoinControl coin_control;
coin_control.nCoinType = CoinType::ONLY_COINJOIN_COLLATERAL;

m_wallet->AvailableCoins(vCoins, &coin_control);
AvailableCoins(*m_wallet, vCoins, &coin_control);

if (vCoins.empty()) {
strReason = strprintf("%s requires a collateral transaction and could not locate an acceptable input!", gCoinJoinName);
Expand Down
5 changes: 3 additions & 2 deletions src/coinjoin/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#include <policy/fees.h>
#include <policy/policy.h>
#include <script/sign.h>
#include <util/translation.h>
#include <wallet/fees.h>
#include <wallet/spend.h>
#include <wallet/wallet.h>
#include <util/translation.h>

#include <numeric>

Expand Down Expand Up @@ -274,7 +275,7 @@ bool CTransactionBuilder::Commit(bilingual_str& strResult)
{
LOCK2(m_wallet.cs_wallet, cs_main);
FeeCalculation fee_calc_out;
if (!m_wallet.CreateTransaction(vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl, fee_calc_out)) {
if (!CreateTransaction(m_wallet, vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl, fee_calc_out)) {
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/rpc/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <util/check.h>
#include <util/strencodings.h>
#include <validation.h>
#include <wallet/receive.h>
#include <wallet/rpc/util.h>
#include <walletinitinterface.h>

Expand Down Expand Up @@ -278,7 +279,7 @@ static RPCHelpMan coinjoinsalt_generate()
}
}

const auto wallet_balance{wallet->GetBalance()};
const auto wallet_balance{GetBalance(*wallet)};
const bool has_balance{(wallet_balance.m_anonymized
+ wallet_balance.m_denominated_trusted
+ wallet_balance.m_denominated_untrusted_pending) > 0};
Expand Down Expand Up @@ -380,7 +381,7 @@ static RPCHelpMan coinjoinsalt_set()
}
}

const auto wallet_balance{wallet->GetBalance()};
const auto wallet_balance{GetBalance(*wallet)};
const bool has_balance{(wallet_balance.m_anonymized
+ wallet_balance.m_denominated_trusted
+ wallet_balance.m_denominated_untrusted_pending) > 0};
Expand Down
6 changes: 4 additions & 2 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#ifdef ENABLE_WALLET
#include <wallet/coincontrol.h>
#include <wallet/rpcwallet.h>
#include <wallet/spend.h>
#include <wallet/wallet.h>
#endif//ENABLE_WALLET

Expand Down Expand Up @@ -256,7 +257,7 @@ static void FundSpecialTx(CWallet& wallet, CMutableTransaction& tx, const Specia
coinControl.fRequireAllInputs = false;

std::vector<COutput> vecOutputs;
wallet.AvailableCoins(vecOutputs);
AvailableCoins(wallet, vecOutputs);

for (const auto& out : vecOutputs) {
CTxDestination txDest;
Expand All @@ -275,7 +276,8 @@ static void FundSpecialTx(CWallet& wallet, CMutableTransaction& tx, const Specia
bilingual_str strFailReason;

FeeCalculation fee_calc_out;
if (!wallet.CreateTransaction(vecSend, newTx, nFee, nChangePos, strFailReason, coinControl, fee_calc_out, false, tx.vExtraPayload.size())) {
if (!CreateTransaction(wallet, vecSend, newTx, nFee, nChangePos, strFailReason, coinControl, fee_calc_out, false,
tx.vExtraPayload.size())) {
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason.original);
}

Expand Down
3 changes: 2 additions & 1 deletion src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <wallet/rpc/util.h>

#ifdef ENABLE_WALLET
#include <wallet/spend.h>
#include <wallet/wallet.h>
#endif // ENABLE_WALLET

Expand Down Expand Up @@ -218,7 +219,7 @@ static RPCHelpMan gobject_prepare()

CTransactionRef tx;

if (!wallet->GetBudgetSystemCollateralTX(tx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
if (!GenBudgetSystemCollateralTx(*wallet, tx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
std::string err = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked.";
if (!request.params[5].isNull() && !request.params[6].isNull()) {
err += "Please verify your specified output is valid and is enough for the combined proposal fee and transaction fee.";
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <wallet/rpc/util.h>

#ifdef ENABLE_WALLET
#include <wallet/spend.h>
#include <wallet/wallet.h>
#endif // ENABLE_WALLET

Expand Down Expand Up @@ -135,7 +136,7 @@ static RPCHelpMan masternode_outputs()
coin_control.nCoinType = CoinType::ONLY_MASTERNODE_COLLATERAL;
{
LOCK(wallet->cs_wallet);
wallet->AvailableCoins(vPossibleCoins, &coin_control);
AvailableCoins(*wallet, vPossibleCoins, &coin_control);
}
UniValue outputsArr(UniValue::VARR);
for (const auto& out : vPossibleCoins) {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/coincontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <optional>

enum class CoinType
enum class CoinType : uint8_t
{
ALL_COINS,
ONLY_FULLY_MIXED,
Expand Down
Loading
Loading