forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: bitcoin#19169, #22621, #25344, #25685, #25730, #25734, #25942, #26462, #26532, #26668 #7646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
knst
wants to merge
15
commits into
dashpay:develop
Choose a base branch
from
knst:bp-v25-p10
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
backport: bitcoin#19169, #22621, #25344, #25685, #25730, #25734, #25942, #26462, #26532, #26668 #7646
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
26d12fa
refactor: carry the coin type in CoinSelectionParams
knst 4ae4ab0
refactor: drop CoinType threading from AttemptSelection/ChooseSelecti…
knst 22441a3
refactor: fold SelectTxDSInsByDenomination overloads into one
knst ee1ba22
Merge bitcoin/bitcoin#25344: New `outputs` argument for `bumpfee`/`ps…
knst fde11c6
partial Merge bitcoin/bitcoin#22621: make ParseOutputType return a st…
knst c215412
partial Merge bitcoin/bitcoin#25734: wallet, refactor: #24584 follow-ups
knst bcea7fb
Merge bitcoin/bitcoin#25685: wallet: Faster transaction creation by r…
knst 79233dd
fix: remove fRequireAllInputs and fix relevant code for bitcoin/bitco…
knst d8c6b9c
Merge #19169: rpc: Validate provided keys for query_options parameter…
knst 912c3b3
Merge bitcoin/bitcoin#25730: RPC: listunspent, add "include immature …
knst 5c3a1d2
Merge bitcoin/bitcoin#26532: wallet: bugfix, invalid crypted key "che…
knst 7cb417d
Merge bitcoin/bitcoin#25942: test: add `ismine` test for descriptor S…
knst 01bb9fd
Merge bitcoin/bitcoin#26462: wallet: fix crash on loading descriptor …
knst 1402e73
Merge bitcoin/bitcoin#26668: wallet: if only have one output type, do…
knst 11df761
partial Merge bitcoin/bitcoin#26699: wallet, gui: bugfix, getAvailabl…
knst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| RPC Wallet | ||
| ---------- | ||
|
|
||
| - RPC `listunspent` now has a new argument `include_immature_coinbase` | ||
| to include coinbase UTXOs that don't meet the minimum spendability | ||
| depth requirement (which before were silently skipped). (#25730) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // Copyright (c) 2022 The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or https://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <bench/bench.h> | ||
| #include <chainparams.h> | ||
| #include <wallet/coincontrol.h> | ||
| #include <consensus/merkle.h> | ||
| #include <kernel/chain.h> | ||
| #include <node/context.h> | ||
| #include <test/util/setup_common.h> | ||
| #include <validation.h> | ||
| #include <wallet/spend.h> | ||
| #include <wallet/test/util.h> | ||
| #include <wallet/wallet.h> | ||
|
|
||
| using wallet::CWallet; | ||
| using wallet::CreateMockWalletDatabase; | ||
| using wallet::DBErrors; | ||
| using wallet::WALLET_FLAG_DESCRIPTORS; | ||
|
|
||
| struct TipBlock | ||
| { | ||
| uint256 prev_block_hash; | ||
| int64_t prev_block_time; | ||
| int tip_height; | ||
| }; | ||
|
|
||
| TipBlock getTip(const CChainParams& params, const node::NodeContext& context) | ||
| { | ||
| auto tip = WITH_LOCK(::cs_main, return context.chainman->ActiveTip()); | ||
| return (tip) ? TipBlock{tip->GetBlockHash(), tip->GetBlockTime(), tip->nHeight} : | ||
| TipBlock{params.GenesisBlock().GetHash(), params.GenesisBlock().GetBlockTime(), 0}; | ||
| } | ||
|
|
||
| void generateFakeBlock(const CChainParams& params, | ||
| const node::NodeContext& context, | ||
| CWallet& wallet, | ||
| const CScript& coinbase_out_script) | ||
| { | ||
| TipBlock tip{getTip(params, context)}; | ||
|
|
||
| // Create block | ||
| CBlock block; | ||
| CMutableTransaction coinbase_tx; | ||
| coinbase_tx.vin.resize(1); | ||
| coinbase_tx.vin[0].prevout.SetNull(); | ||
| coinbase_tx.vout.resize(2); | ||
| coinbase_tx.vout[0].scriptPubKey = coinbase_out_script; | ||
| coinbase_tx.vout[0].nValue = 49 * COIN; | ||
| coinbase_tx.vin[0].scriptSig = CScript() << ++tip.tip_height << OP_0; | ||
| coinbase_tx.vout[1].scriptPubKey = coinbase_out_script; // extra output | ||
| coinbase_tx.vout[1].nValue = 1 * COIN; | ||
| block.vtx = {MakeTransactionRef(std::move(coinbase_tx))}; | ||
|
|
||
| block.nVersion = VERSIONBITS_LAST_OLD_BLOCK_VERSION; | ||
| block.hashPrevBlock = tip.prev_block_hash; | ||
| block.hashMerkleRoot = BlockMerkleRoot(block); | ||
| block.nTime = ++tip.prev_block_time; | ||
| block.nBits = params.GenesisBlock().nBits; | ||
| block.nNonce = 0; | ||
|
|
||
| { | ||
| LOCK(::cs_main); | ||
| // Add it to the index | ||
| const uint256 hash{block.GetHash()}; | ||
| CBlockIndex* pindex{context.chainman->m_blockman.AddToBlockIndex(block, hash, context.chainman->m_best_header)}; | ||
| // add it to the chain | ||
| context.chainman->ActiveChain().SetTip(*pindex); | ||
| } | ||
|
|
||
| // notify wallet | ||
| const auto& pindex = WITH_LOCK(::cs_main, return context.chainman->ActiveChain().Tip()); | ||
| wallet.blockConnected(kernel::MakeBlockInfo(pindex, &block)); | ||
| } | ||
|
|
||
| struct PreSelectInputs { | ||
| // How many coins from the wallet the process should select | ||
| int num_of_internal_inputs; | ||
| // future: this could have external inputs as well. | ||
| }; | ||
|
|
||
| static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type, bool allow_other_inputs, std::optional<PreSelectInputs> preset_inputs) | ||
| { | ||
| const auto test_setup = MakeNoLogFileContext<const TestingSetup>(); | ||
|
|
||
| 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); | ||
| wallet.SetupDescriptorScriptPubKeyMans("", ""); | ||
| if (wallet.LoadWallet() != DBErrors::LOAD_OK) assert(false); | ||
| } | ||
|
|
||
| // Generate destinations | ||
| CScript dest = GetScriptForDestination(getNewDestination(wallet)); | ||
|
|
||
| // Generate chain; each coinbase will have two outputs to fill-up the wallet | ||
| const auto& params = Params(); | ||
| unsigned int chain_size = 5000; // 5k blocks means 10k UTXO for the wallet (minus 200 due COINBASE_MATURITY) | ||
| for (unsigned int i = 0; i < chain_size; ++i) { | ||
| generateFakeBlock(params, test_setup->m_node, wallet, dest); | ||
| } | ||
|
|
||
| // Check available balance | ||
| auto bal = WITH_LOCK(wallet.cs_wallet, return wallet::AvailableCoins(wallet).total_amount); // Cache | ||
| assert(bal == 50 * COIN * (chain_size - COINBASE_MATURITY)); | ||
|
|
||
| wallet::CCoinControl coin_control; | ||
| coin_control.m_allow_other_inputs = allow_other_inputs; | ||
|
|
||
| CAmount target = 0; | ||
| if (preset_inputs) { | ||
| // Select inputs, each has 49 BTC | ||
| wallet::CoinFilterParams filter_coins; | ||
| filter_coins.max_count = preset_inputs->num_of_internal_inputs; | ||
| const auto& res = WITH_LOCK(wallet.cs_wallet, | ||
| return wallet::AvailableCoins(wallet, /*coinControl=*/nullptr, /*feerate=*/std::nullopt, filter_coins)); | ||
| for (int i=0; i < preset_inputs->num_of_internal_inputs; i++) { | ||
| const auto& coin{res.coins.at(output_type)[i]}; | ||
| target += coin.txout.nValue; | ||
| coin_control.Select(coin.outpoint); | ||
| } | ||
| } | ||
|
|
||
| // If automatic coin selection is enabled, add the value of another UTXO to the target | ||
| if (coin_control.m_allow_other_inputs) target += 50 * COIN; | ||
| std::vector<wallet::CRecipient> recipients = {{dest, target, true}}; | ||
|
|
||
| bench.epochIterations(5).run([&] { | ||
| LOCK(wallet.cs_wallet); | ||
| const auto& tx_res = CreateTransaction(wallet, recipients, -1, coin_control); | ||
| assert(tx_res); | ||
| }); | ||
| } | ||
|
|
||
| static void WalletCreateTxUseOnlyPresetInputs(benchmark::Bench& bench) { WalletCreateTx(bench, OutputType::LEGACY, /*allow_other_inputs=*/false, | ||
| {{/*num_of_internal_inputs=*/4}}); } | ||
|
|
||
| static void WalletCreateTxUsePresetInputsAndCoinSelection(benchmark::Bench& bench) { WalletCreateTx(bench, OutputType::LEGACY, /*allow_other_inputs=*/true, | ||
| {{/*num_of_internal_inputs=*/4}}); } | ||
|
|
||
| BENCHMARK(WalletCreateTxUseOnlyPresetInputs, benchmark::PriorityLevel::LOW) | ||
| BENCHMARK(WalletCreateTxUsePresetInputsAndCoinSelection, benchmark::PriorityLevel::LOW) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.