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
40 changes: 20 additions & 20 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void CoinSelection(benchmark::Bench& bench)
{
NodeContext node;
auto chain = interfaces::MakeChain(node);
CWallet wallet(chain.get(), /*coinjoin_loader=*/ nullptr, "", CreateDummyWalletDatabase());
CWallet wallet(chain.get(), /*coinjoin_loader=*/nullptr, "", gArgs, CreateDummyWalletDatabase());
std::vector<std::unique_ptr<CWalletTx>> wtxs;
LOCK(wallet.cs_wallet);

Expand All @@ -45,34 +45,37 @@ static void CoinSelection(benchmark::Bench& bench)
// Create coins
std::vector<COutput> coins;
for (const auto& wtx : wtxs) {
coins.emplace_back(wallet, *wtx, 0 /* iIn */, 6 * 24 /* nDepthIn */, true /* spendable */, true /* solvable */, true /* safe */);
coins.emplace_back(COutPoint(wtx->GetHash(), 0), wtx->tx->vout.at(0), /*depth=*/ 6 * 24, GetTxSpendSize(wallet, *wtx, 0), /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ true, wtx->GetTxTime(), /*from_me=*/ true);
}
const CoinEligibilityFilter filter_standard(1, 6, 0);
const CoinSelectionParams coin_selection_params(/* change_output_size= */ 34,
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
/* tx_noinputs_size= */ 0, /* avoid_partial= */ false);
FastRandomContext rand{};
const CoinSelectionParams coin_selection_params{
rand,
/* change_output_size= */ 34,
/* change_spend_size= */ 148,
/* effective_feerate= */ CFeeRate(0),
/* long_term_feerate= */ CFeeRate(0),
/* discard_feerate= */ CFeeRate(0),
/* tx_noinputs_size= */ 0,
/* avoid_partial= */ false,
};
bench.run([&] {
std::set<CInputCoin> setCoinsRet;
CAmount nValueRet;
bool success = AttemptSelection(wallet, 1003 * COIN, filter_standard, coins, setCoinsRet, nValueRet, coin_selection_params);
assert(success);
assert(nValueRet == 1003 * COIN);
assert(setCoinsRet.size() == 2);
auto result = AttemptSelection(wallet, 1003 * COIN, filter_standard, coins, coin_selection_params);
assert(result);
assert(result->GetSelectedValue() == 1003 * COIN);
assert(result->GetInputSet().size() == 2);
});
}

typedef std::set<CInputCoin> CoinSet;

// Copied from src/wallet/test/coinselector_tests.cpp
static void add_coin(const CAmount& nValue, int nInput, std::vector<OutputGroup>& set)
{
CMutableTransaction tx;
tx.vout.resize(nInput + 1);
tx.vout[nInput].nValue = nValue;
CInputCoin coin(MakeTransactionRef(tx), nInput);
COutput output(COutPoint(tx.GetHash(), nInput), tx.vout.at(nInput), /*depth=*/ 0, /*input_bytes=*/ -1, /*spendable=*/ true, /*solvable=*/ true, /*safe=*/ true, /*time=*/ 0, /*from_me=*/ true);
set.emplace_back();
set.back().Insert(coin, 0, true, 0, 0, false);
set.back().Insert(output, /*ancestors=*/ 0, /*descendants=*/ 0, /*positive_only=*/ false);
}
// Copied from src/wallet/test/coinselector_tests.cpp
static CAmount make_hard_case(int utxos, std::vector<OutputGroup>& utxo_pool)
Expand All @@ -91,17 +94,14 @@ static void BnBExhaustion(benchmark::Bench& bench)
{
// Setup
std::vector<OutputGroup> utxo_pool;
CoinSet selection;
CAmount value_ret = 0;

bench.run([&] {
// Benchmark
CAmount target = make_hard_case(17, utxo_pool);
SelectCoinsBnB(utxo_pool, target, 0, selection, value_ret); // Should exhaust
SelectCoinsBnB(utxo_pool, target, 0); // Should exhaust

// Cleanup
utxo_pool.clear();
selection.clear();
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
const auto& ADDRESS_WATCHONLY = ADDRESS_B58T_UNSPENDABLE;

CWallet wallet{test_setup->m_node.chain.get(), test_setup->m_node.coinjoin_loader.get(), "", CreateMockWalletDatabase()};
CWallet wallet{test_setup->m_node.chain.get(), test_setup->m_node.coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()};
{
LOCK(wallet.cs_wallet);
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand Down
10 changes: 5 additions & 5 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,12 +1468,12 @@ bool CCoinJoinClientSession::MakeCollateralAmounts(const CompactTallyItem& tally
if (!CCoinJoinClientOptions::IsEnabled()) return false;

// Denominated input is always a single one, so we can check its amount directly and return early
if (!fTryDenominated && tallyItem.vecInputCoins.size() == 1 && CoinJoin::IsDenominatedAmount(tallyItem.nAmount)) {
if (!fTryDenominated && tallyItem.outpoints.size() == 1 && CoinJoin::IsDenominatedAmount(tallyItem.nAmount)) {
return false;
}

// Skip single inputs that can be used as collaterals already
if (tallyItem.vecInputCoins.size() == 1 && CoinJoin::IsCollateralAmount(tallyItem.nAmount)) {
if (tallyItem.outpoints.size() == 1 && CoinJoin::IsCollateralAmount(tallyItem.nAmount)) {
return false;
}

Expand Down Expand Up @@ -1562,10 +1562,10 @@ bool CCoinJoinClientSession::CreateCollateralTransaction(CMutableTransaction& tx
}

const auto& output = vCoins.at(GetRand(vCoins.size()));
const CTxOut txout = output.tx->tx->vout[output.i];
const CTxOut txout = output.txout;

txCollateral.vin.clear();
txCollateral.vin.emplace_back(output.tx->GetHash(), output.i);
txCollateral.vin.emplace_back(output.outpoint.hash, output.outpoint.n);
txCollateral.vout.clear();

// pay collateral charge in fees
Expand Down Expand Up @@ -1636,7 +1636,7 @@ bool CCoinJoinClientSession::CreateDenominated(CAmount nBalanceToDenominate, con
if (!CCoinJoinClientOptions::IsEnabled()) return false;

// denominated input is always a single one, so we can check its amount directly and return early
if (tallyItem.vecInputCoins.size() == 1 && CoinJoin::IsDenominatedAmount(tallyItem.nAmount)) {
if (tallyItem.outpoints.size() == 1 && CoinJoin::IsDenominatedAmount(tallyItem.nAmount)) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/coinjoin/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ CTransactionBuilder::CTransactionBuilder(CWallet& wallet, const CompactTallyItem
// Create dummy tx to calculate the exact required fees upfront for accurate amount and fee calculations
CMutableTransaction dummyTx;
// Select all tallyItem outputs in the coinControl so that CreateTransaction knows what to use
for (const auto& coin : tallyItem.vecInputCoins) {
coinControl.Select(coin.outpoint);
dummyTx.vin.emplace_back(coin.outpoint, CScript());
for (const auto& outpoint : tallyItem.outpoints) {
coinControl.Select(outpoint);
dummyTx.vin.emplace_back(outpoint, CScript());
}
// Get a comparable dummy scriptPubKey, avoid writing/flushing to the actual wallet db
CScript dummyScript;
Expand Down
3 changes: 0 additions & 3 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ class Chain
//! or one of its ancestors.
virtual std::optional<int> findLocatorFork(const CBlockLocator& locator) = 0;

//! Check if transaction will be final given chain height current time.
virtual bool checkFinalTx(const CTransaction& tx) = 0;

//! Check if transaction is locked by InstantSendManager
virtual bool isInstantSendLockedTx(const uint256& hash) = 0;

Expand Down
1 change: 0 additions & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ struct WalletTxStatus
int depth_in_main_chain;
unsigned int time_received;
uint32_t lock_time;
bool is_final;
bool is_trusted;
bool is_abandoned;
bool is_coinbase;
Expand Down
5 changes: 0 additions & 5 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,6 @@ class ChainImpl : public Chain
}
return std::nullopt;
}
bool checkFinalTx(const CTransaction& tx) override
{
LOCK(cs_main);
return CheckFinalTxAtTip(*Assert(m_node.chainman->ActiveChain().Tip()), tx);
}
bool isInstantSendLockedTx(const uint256& hash) override
{
if (m_node.llmq_ctx == nullptr || m_node.llmq_ctx->isman == nullptr) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/test/addressbooktests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
{
TestChain100Setup test;
node.setContext(&test.m_node);
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", CreateMockWalletDatabase());
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase());
wallet->LoadWallet();
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void TestGUI(interfaces::Node& node)
}
node.setContext(&test.m_node);
WalletContext& context = *node.walletLoader().context();
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", CreateMockWalletDatabase());
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase());
AddWallet(context, wallet);
wallet->LoadWallet();
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand Down
9 changes: 0 additions & 9 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <key_io.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <script/script.h>
#include <util/system.h>
#include <validation.h>
#include <wallet/ismine.h>
Expand All @@ -30,14 +29,6 @@

QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
{
if (!status.is_final)
{
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
return tr("Open for %n more block(s)", "", wtx.tx->nLockTime - numBlocks);
else
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.tx->nLockTime));
}
else
{
int nDepth = status.depth_in_main_chain;
if (nDepth < 0) return tr("conflicted");
Expand Down
15 changes: 1 addition & 14 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,8 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons
status.lockedByChainLocks = wtx.is_chainlocked;
status.lockedByInstantSend = wtx.is_islocked;

const bool up_to_date = ((int64_t)QDateTime::currentMSecsSinceEpoch() / 1000 - block_time < MAX_BLOCK_TIME_GAP);
if (up_to_date && !wtx.is_final) {
if (wtx.lock_time < LOCKTIME_THRESHOLD) {
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = wtx.lock_time - numBlocks;
}
else
{
status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.lock_time;
}
}
// For generated transactions, determine maturity
else if(type == TransactionRecord::Generated)
{
if (type == TransactionRecord::Generated) {
if (wtx.blocks_to_maturity > 0)
{
status.status = TransactionStatus::Immature;
Expand Down
2 changes: 0 additions & 2 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class TransactionStatus
enum Status {
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
/// Normal (sent/received) transactions
OpenUntilDate, /**< Transaction not yet final, waiting for date */
OpenUntilBlock, /**< Transaction not yet final, waiting for block */
Unconfirmed, /**< Not yet mined into a block **/
Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/
Conflicted, /**< Conflicts with other transaction or mempool **/
Expand Down
9 changes: 0 additions & 9 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons

switch(wtx->status.status)
{
case TransactionStatus::OpenUntilBlock:
status = tr("Open for %n more block(s)","",wtx->status.open_for);
break;
case TransactionStatus::OpenUntilDate:
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
break;
case TransactionStatus::Unconfirmed:
status = tr("Unconfirmed");
break;
Expand Down Expand Up @@ -564,9 +558,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
{
switch(wtx->status.status)
{
case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate:
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::TX_STATUS_OPENUNTILDATE);
case TransactionStatus::Unconfirmed:
return GUIUtil::getIcon("transaction_0");
case TransactionStatus::Abandoned:
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ static void FundSpecialTx(CWallet& wallet, CMutableTransaction& tx, const Specia

for (const auto& out : vecOutputs) {
CTxDestination txDest;
if (ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, txDest) && txDest == fundDest) {
coinControl.Select(COutPoint(out.tx->tx->GetHash(), out.i));
if (ExtractDestination(out.txout.scriptPubKey, txDest) && txDest == fundDest) {
coinControl.Select(out.outpoint);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static RPCHelpMan masternode_outputs()
}
UniValue outputsArr(UniValue::VARR);
for (const auto& out : vPossibleCoins) {
outputsArr.push_back(out.GetInputCoin().outpoint.ToStringShort());
outputsArr.push_back(out.outpoint.ToStringShort());
}

return outputsArr;
Expand Down
16 changes: 8 additions & 8 deletions src/wallet/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ bool CWallet::SelectTxDSInsByDenomination(int nDenom, CAmount nValueMax, std::ve
Shuffle(vCoins.rbegin(), vCoins.rend(), FastRandomContext());

for (const auto& out : vCoins) {
uint256 txHash = out.tx->GetHash();
CAmount nValue = out.tx->tx->vout[out.i].nValue;
uint256 txHash = out.outpoint.hash;
CAmount nValue = out.txout.nValue;
if (setRecentTxIds.find(txHash) != setRecentTxIds.end()) continue; // no duplicate txids
if (nValueTotal + nValue > nValueMax) continue;
if (nValue != nDenomAmount) continue;

CTxIn txin = CTxIn(txHash, out.i);
CScript scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
CTxIn txin = CTxIn(txHash, out.outpoint.n);
CScript scriptPubKey = out.txout.scriptPubKey;
int nRounds = GetRealOutpointCoinJoinRounds(txin.prevout);

nValueTotal += nValue;
Expand All @@ -95,7 +95,7 @@ struct CompareByPriority
bool operator()(const COutput& t1,
const COutput& t2) const
{
return CoinJoin::CalculateAmountPriority(t1.GetInputCoin().effective_value) > CoinJoin::CalculateAmountPriority(t2.GetInputCoin().effective_value);
return CoinJoin::CalculateAmountPriority(t1.effective_value) > CoinJoin::CalculateAmountPriority(t2.effective_value);
}
};

Expand All @@ -114,7 +114,7 @@ bool CWallet::SelectDenominatedAmounts(CAmount nValueMax, std::set<CAmount>& set
std::sort(vCoins.rbegin(), vCoins.rend(), CompareByPriority());

for (const auto& out : vCoins) {
CAmount nValue = out.tx->tx->vout[out.i].nValue;
CAmount nValue = out.txout.nValue;
if (nValueTotal + nValue <= nValueMax) {
nValueTotal += nValue;
setAmountsRet.emplace(nValue);
Expand Down Expand Up @@ -169,7 +169,7 @@ std::vector<CompactTallyItem> CWallet::SelectCoinsGroupedByAddresses(bool fSkipD
if(!(mine & filter)) continue;

auto itTallyItem = mapTally.find(txdest);
if (nMaxOupointsPerAddress != -1 && itTallyItem != mapTally.end() && int64_t(itTallyItem->second.vecInputCoins.size()) >= nMaxOupointsPerAddress) continue;
if (nMaxOupointsPerAddress != -1 && itTallyItem != mapTally.end() && int64_t(itTallyItem->second.outpoints.size()) >= nMaxOupointsPerAddress) continue;

if(IsSpent(outpoint.hash, i) || IsLockedCoin(outpoint.hash, i)) continue;

Expand All @@ -191,7 +191,7 @@ std::vector<CompactTallyItem> CWallet::SelectCoinsGroupedByAddresses(bool fSkipD
itTallyItem->second.txdest = txdest;
}
itTallyItem->second.nAmount += wtx.tx->vout[i].nValue;
itTallyItem->second.vecInputCoins.emplace_back(wtx.tx, i);
itTallyItem->second.outpoints.emplace_back(COutPoint{outpoint.hash, i});
}
}

Expand Down
Loading
Loading