Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
39557f9
fix: include `BOOST_AUTO_TEST_SUITE_END` within namespace `wallet`
kwvg Jul 13, 2025
f447b5d
merge bitcoin#24711: Postpone wallet loading notification for encrypt…
kwvg Mar 29, 2022
a883a8e
merge bitcoin#24666: Fix coinselection.h include, Make COutput a struct
kwvg Jun 23, 2025
ae24276
merge bitcoin#25083: Set effective_value when initializing a COutput
kwvg Jun 24, 2025
a498336
refactor: use initializer to set `nCoinType` instead of manual assign…
kwvg Jun 23, 2025
2438b9f
merge bitcoin#25005: remove extra wtx lookup in 'AvailableCoins' + se…
kwvg Jun 24, 2025
51237c9
merge bitcoin#25410: fix warning: "argument name 'feerate' in comment…
kwvg Jun 18, 2022
a0b2c7d
fix: make `get_previous_releases.py` understand windows target triples
kwvg Jun 23, 2025
1026f11
fix: make `get_previous_release.py` translate triples for pre-v0.12.2.x
kwvg Jun 24, 2025
7b6af94
fix: allow argument-free RPC calls with nodes running v0.12.2.x and l…
kwvg Jun 24, 2025
d13ff52
fix: use URL quoting for password fields due to Base64 in pre-v0.12.2.x
kwvg Jun 24, 2025
79fcd30
merge bitcoin#24236: Remove utxo db upgrade code
kwvg Jun 24, 2025
e2f053a
merge bitcoin#25438: remove unused methods in classes `CDBIterator,CD…
kwvg Jun 20, 2022
4aafd98
merge bitcoin#25036: Save wallet scan progress
kwvg Jun 23, 2025
48f5c10
merge bitcoin#25489: change `ScanForWalletTransactions` to use `Ticks…
kwvg Jul 12, 2022
db7e174
merge bitcoin#25544: don't iter twice when getting the cached debit/c…
kwvg Jul 5, 2022
9f5845c
partial bitcoin#25218: introduce generic 'Result' class and connect i…
kwvg Apr 8, 2022
b75f1ad
partial bitcoin#26005: Fix error handling (copy_file failure in Resto…
kwvg Sep 4, 2022
27933a7
merge bitcoin#25594: Return BResult from restoreWallet
kwvg Jul 12, 2022
175970e
merge bitcoin#13226: Optimize SelectCoinsBnB by tracking the selectio…
kwvg May 8, 2018
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: 1 addition & 1 deletion ci/test/00_setup_env_native_qt5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude fe
export RUN_UNIT_TESTS_SEQUENTIAL="true"
export RUN_UNIT_TESTS="false"
export GOAL="install"
export PREVIOUS_RELEASES_TO_DOWNLOAD="v0.15.0.0 v0.16.1.1 v0.17.0.3 v18.2.2 v19.3.0 v20.0.1"
export PREVIOUS_RELEASES_TO_DOWNLOAD="v0.12.1.5 v0.15.0.0 v0.16.1.1 v0.17.0.3 v18.2.2 v19.3.0 v20.0.1"
export BITCOIN_CONFIG="--enable-zmq --with-libs=no --enable-reduce-exports --disable-fuzz-binary LDFLAGS=-static-libstdc++ --with-boost-process"
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ BITCOIN_CORE_H = \
util/overloaded.h \
util/ranges.h \
util/readwritefile.h \
util/result.h \
util/underlying.h \
util/serfloat.h \
util/settings.h \
Expand Down
4 changes: 2 additions & 2 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void CoinSelection(benchmark::Bench& bench)
// Create coins
std::vector<COutput> coins;
for (const auto& wtx : wtxs) {
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);
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, /*fees=*/ 0);
}
const CoinEligibilityFilter filter_standard(1, 6, 0);
FastRandomContext rand{};
Expand Down Expand Up @@ -85,7 +85,7 @@ static void add_coin(const CAmount& nValue, int nInput, std::vector<OutputGroup>
CMutableTransaction tx;
tx.vout.resize(nInput + 1);
tx.vout[nInput].nValue = nValue;
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);
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, /*fees=*/ 0);
set.emplace_back();
set.back().Insert(output, /*ancestors=*/ 0, /*descendants=*/ 0, /*positive_only=*/ false);
}
Expand Down
8 changes: 2 additions & 6 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,12 +1557,8 @@ bool CCoinJoinClientSession::CreateCollateralTransaction(CMutableTransaction& tx
{
AssertLockHeld(m_wallet->cs_wallet);

std::vector<COutput> vCoins;
CCoinControl coin_control;
coin_control.nCoinType = CoinType::ONLY_COINJOIN_COLLATERAL;

AvailableCoins(*m_wallet, vCoins, &coin_control);

CCoinControl coin_control(CoinType::ONLY_COINJOIN_COLLATERAL);
std::vector<COutput> vCoins{AvailableCoinsListUnspent(*m_wallet, &coin_control).coins};
if (vCoins.empty()) {
strReason = strprintf("%s requires a collateral transaction and could not locate an acceptable input!", gCoinJoinName);
return false;
Expand Down
1 change: 1 addition & 0 deletions src/coinjoin/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BITCOIN_COINJOIN_UTIL_H
#define BITCOIN_COINJOIN_UTIL_H

#include <wallet/coincontrol.h>
#include <wallet/wallet.h>

class CTransactionBuilder;
Expand Down
1 change: 0 additions & 1 deletion src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class CCoinsViewCursor

virtual bool GetKey(COutPoint &key) const = 0;
virtual bool GetValue(Coin &coin) const = 0;
virtual unsigned int GetValueSize() const = 0;

virtual bool Valid() const = 0;
virtual void Next() = 0;
Expand Down
22 changes: 0 additions & 22 deletions src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ class CDBIterator
}
return true;
}

unsigned int GetValueSize() {
return piter->value().size();
}

};

class CDBWrapper
Expand Down Expand Up @@ -373,27 +368,10 @@ class CDBWrapper
return size;
}

/**
* Compact a certain range of keys in the database.
*/
template<typename K>
void CompactRange(const K& key_begin, const K& key_end) const
{
CDataStream ssKey1(SER_DISK, CLIENT_VERSION), ssKey2(SER_DISK, CLIENT_VERSION);
ssKey1.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
ssKey1 << key_begin;
ssKey2 << key_end;
leveldb::Slice slKey1(CharCast(ssKey1.data()), ssKey1.size());
leveldb::Slice slKey2(CharCast(ssKey2.data()), ssKey2.size());
pdb->CompactRange(&slKey1, &slKey2);
}

void CompactFull() const
{
pdb->CompactRange(nullptr, nullptr);
}

};

template<typename CDBTransaction>
Expand Down
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2037,8 +2037,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
strLoadError = _("Error initializing block database");
break;
case ChainstateLoadingError::ERROR_CHAINSTATE_UPGRADE_FAILED:
strLoadError = _("Error upgrading chainstate database");
break;
return InitError(_("Unsupported chainstate database format found. "
"Please restart with -reindex-chainstate. This will "
"rebuild the chainstate database."));
case ChainstateLoadingError::ERROR_REPLAYBLOCKS_FAILED:
strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
break;
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class Chain
//! Get locator for the current chain tip.
virtual CBlockLocator getTipLocator() = 0;

//! Return a locator that refers to a block in the active chain.
//! If specified block is not in the active chain, return locator for the latest ancestor that is in the chain.
virtual CBlockLocator getActiveChainLocator(const uint256& block_hash) = 0;

//! Return height of the highest block on chain in common with the locator,
//! which will either be the original block used to create the locator,
//! or one of its ancestors.
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <script/standard.h> // For CTxDestination
#include <support/allocators/secure.h> // For SecureString
#include <util/message.h>
#include <util/result.h>
#include <util/ui_change_type.h>

#include <cstdint>
Expand Down Expand Up @@ -357,7 +358,7 @@ class WalletLoader : public ChainClient
virtual std::string getWalletDir() = 0;

//! Restore backup wallet
virtual std::unique_ptr<Wallet> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, bilingual_str& error, std::vector<bilingual_str>& warnings) = 0;
virtual BResult<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings) = 0;

//! Return available wallets in wallet directory.
virtual std::vector<std::string> listWalletDir() = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
chainstate->CoinsErrorCatcher().AddReadErrCallback(coins_error_cb);
}

// If necessary, upgrade from older database format.
// Refuse to load unsupported database format.
// This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
if (!chainstate->CoinsDB().Upgrade()) {
if (chainstate->CoinsDB().NeedsUpgrade()) {
return ChainstateLoadingError::ERROR_CHAINSTATE_UPGRADE_FAILED;
}

Expand Down
17 changes: 12 additions & 5 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ class ChainImpl : public Chain
}
bool haveBlockOnDisk(int height) override
{
LOCK(cs_main);
LOCK(::cs_main);
const CChain& active = Assert(m_node.chainman)->ActiveChain();
CBlockIndex* block = active[height];
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
Expand All @@ -758,12 +758,19 @@ class ChainImpl : public Chain
}
CBlockLocator getTipLocator() override
{
LOCK(cs_main);
LOCK(::cs_main);
return chainman().ActiveChain().GetLocator();
}
CBlockLocator getActiveChainLocator(const uint256& block_hash) override
{
LOCK(::cs_main);
const CBlockIndex* index = chainman().m_blockman.LookupBlockIndex(block_hash);
if (!index) return {};
return chainman().ActiveChain().GetLocator(index);
}
std::optional<int> findLocatorFork(const CBlockLocator& locator) override
{
LOCK(cs_main);
LOCK(::cs_main);
const CChainState& active = Assert(m_node.chainman)->ActiveChainstate();
if (const CBlockIndex* fork = active.FindForkInGlobalIndex(locator)) {
return fork->nHeight;
Expand Down Expand Up @@ -845,7 +852,7 @@ class ChainImpl : public Chain
void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
double guessVerificationProgress(const uint256& block_hash) override
{
LOCK(cs_main);
LOCK(::cs_main);
return GuessVerificationProgress(Params().TxData(), chainman().m_blockman.LookupBlockIndex(block_hash));
}
bool hasBlocks(const uint256& block_hash, int min_height, std::optional<int> max_height) override
Expand Down Expand Up @@ -935,7 +942,7 @@ class ChainImpl : public Chain
CFeeRate relayDustFee() override { return ::dustRelayFee; }
bool havePruned() override
{
LOCK(cs_main);
LOCK(::cs_main);
return m_node.chainman->m_blockman.m_have_pruned;
}
bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); }
Expand Down
3 changes: 2 additions & 1 deletion src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#include <qt/optionsmodel.h>
#include <qt/walletmodel.h>

#include <wallet/coincontrol.h>
#include <interfaces/node.h>
#include <key_io.h>
#include <policy/policy.h>
#include <wallet/coincontrol.h>
#include <wallet/coinselection.h>
#include <wallet/wallet.h>

#include <QApplication>
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 @@ -142,7 +142,7 @@ void TestGUI(interfaces::Node& node)
{
WalletRescanReserver reserver(*wallet);
reserver.reserve();
CWallet::ScanResult result = wallet->ScanForWalletTransactions(Params().GetConsensus().hashGenesisBlock, 0 /* start_height */, {} /* max_height */, reserver, true /* fUpdate */);
CWallet::ScanResult result = wallet->ScanForWalletTransactions(Params().GetConsensus().hashGenesisBlock, /*start_height=*/0, /*max_height=*/{}, reserver, /*fUpdate=*/true, /*save_progress=*/false);
QCOMPARE(result.status, CWallet::ScanResult::SUCCESS);
QCOMPARE(result.last_scanned_block, node.context()->chainman->ActiveChain().Tip()->GetBlockHash());
QVERIFY(result.last_failed_block.IsNull());
Expand Down
5 changes: 3 additions & 2 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,10 @@ void RestoreWalletActivity::restore(const fs::path& backup_file, const std::stri
tr("Restoring Wallet <b>%1</b>…").arg(name.toHtmlEscaped()));

QTimer::singleShot(0, worker(), [this, backup_file, wallet_name] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().restoreWallet(backup_file, wallet_name, m_error_message, m_warning_message);
auto wallet{node().walletLoader().restoreWallet(backup_file, wallet_name, m_warning_message)};

if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
m_error_message = wallet ? bilingual_str{} : wallet.GetError();
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(wallet.ReleaseObj());

QTimer::singleShot(0, this, &RestoreWalletActivity::finish);
});
Expand Down
2 changes: 1 addition & 1 deletion src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class WalletModelTransaction;

class CKeyID;
class COutPoint;
class COutput;
class CPubKey;
class uint256;
struct COutput;

namespace interfaces {
class Node;
Expand Down
7 changes: 2 additions & 5 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,7 @@ static void FundSpecialTx(CWallet& wallet, CMutableTransaction& tx, const Specia
coinControl.destChange = fundDest;
coinControl.fRequireAllInputs = false;

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

for (const auto& out : vecOutputs) {
for (const auto& out : AvailableCoinsListUnspent(wallet).coins) {
CTxDestination txDest;
if (ExtractDestination(out.txout.scriptPubKey, txDest) && txDest == fundDest) {
coinControl.Select(out.outpoint);
Expand Down Expand Up @@ -802,7 +799,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
// referencing external collateral

const bool unlockOnError = [&]() {
if (LOCK(pwallet->cs_wallet); !pwallet->IsLockedCoin(ptx.collateralOutpoint.hash, ptx.collateralOutpoint.n)) {
if (LOCK(pwallet->cs_wallet); !pwallet->IsLockedCoin(ptx.collateralOutpoint)) {
pwallet->LockCoin(ptx.collateralOutpoint);
return true;
}
Expand Down
11 changes: 3 additions & 8 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,10 @@ static RPCHelpMan masternode_outputs()
if (!wallet) return NullUniValue;

// Find possible candidates
std::vector<COutput> vPossibleCoins;
CCoinControl coin_control;
coin_control.nCoinType = CoinType::ONLY_MASTERNODE_COLLATERAL;
{
LOCK(wallet->cs_wallet);
AvailableCoins(*wallet, vPossibleCoins, &coin_control);
}
CCoinControl coin_control(CoinType::ONLY_MASTERNODE_COLLATERAL);

UniValue outputsArr(UniValue::VARR);
for (const auto& out : vPossibleCoins) {
for (const auto& out : WITH_LOCK(wallet->cs_wallet, return AvailableCoinsListUnspent(*wallet, &coin_control).coins)) {
outputsArr.push_back(out.outpoint.ToStringShort());
}

Expand Down
Loading
Loading