diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index c9f27fd217eb..2915a3fd80ff 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -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> wtxs; LOCK(wallet.cs_wallet); @@ -45,34 +45,37 @@ static void CoinSelection(benchmark::Bench& bench) // Create coins std::vector 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 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 CoinSet; - // Copied from src/wallet/test/coinselector_tests.cpp static void add_coin(const CAmount& nValue, int nInput, std::vector& 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& utxo_pool) @@ -91,17 +94,14 @@ static void BnBExhaustion(benchmark::Bench& bench) { // Setup std::vector 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(); }); } diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index c49df3085b81..dbc522615991 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -19,7 +19,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b const auto test_setup = MakeNoLogFileContext(); 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); diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 8ae8a666c30a..5268a29e4a81 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -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; } @@ -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 @@ -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; } diff --git a/src/coinjoin/util.cpp b/src/coinjoin/util.cpp index 11ea35449447..2537a1cedcb9 100644 --- a/src/coinjoin/util.cpp +++ b/src/coinjoin/util.cpp @@ -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; diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 8006de91dbeb..6a8dd5bbc3c8 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -133,9 +133,6 @@ class Chain //! or one of its ancestors. virtual std::optional 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; diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 9feef86db5c9..c0fbd86cfc2f 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -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; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index b2a2aff11319..3f1a7e9517e3 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -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; diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index f1e6bd118516..fa7a361b2683 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -64,7 +64,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node) { TestChain100Setup test; node.setContext(&test.m_node); - const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", CreateMockWalletDatabase()); + const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()); wallet->LoadWallet(); wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS); { diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index 04f5f10e7368..ae1f5fa71d45 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -110,7 +110,7 @@ void TestGUI(interfaces::Node& node) } node.setContext(&test.m_node); WalletContext& context = *node.walletLoader().context(); - const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", CreateMockWalletDatabase()); + const std::shared_ptr wallet = std::make_shared(node.context()->chain.get(), node.context()->coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()); AddWallet(context, wallet); wallet->LoadWallet(); wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index e50d87bf60d3..47f8918b2056 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -18,7 +18,6 @@ #include #include #include -#include