mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Add src/wallet/* code to wallet:: namespace
This commit is contained in:
parent
90fc8b089d
commit
f7086fd8ff
94 changed files with 294 additions and 75 deletions
|
@ -12,6 +12,17 @@
|
|||
#include <set>
|
||||
|
||||
using node::NodeContext;
|
||||
using wallet::AttemptSelection;
|
||||
using wallet::CInputCoin;
|
||||
using wallet::COutput;
|
||||
using wallet::CWallet;
|
||||
using wallet::CWalletTx;
|
||||
using wallet::CoinEligibilityFilter;
|
||||
using wallet::CoinSelectionParams;
|
||||
using wallet::CreateDummyWalletDatabase;
|
||||
using wallet::OutputGroup;
|
||||
using wallet::SelectCoinsBnB;
|
||||
using wallet::TxStateInactive;
|
||||
|
||||
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
|
||||
#include <optional>
|
||||
|
||||
using wallet::CWallet;
|
||||
using wallet::CreateMockWalletDatabase;
|
||||
using wallet::DBErrors;
|
||||
using wallet::GetBalance;
|
||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||
|
||||
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine)
|
||||
{
|
||||
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||
|
|
|
@ -123,7 +123,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
ECCVerifyHandle globalVerifyHandle;
|
||||
ECC_Start();
|
||||
if (!WalletTool::ExecuteWalletToolFunc(args, command->command)) {
|
||||
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ECC_Stop();
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <walletinitinterface.h>
|
||||
|
||||
class ArgsManager;
|
||||
class CWallet;
|
||||
|
||||
namespace interfaces {
|
||||
class Chain;
|
||||
|
@ -59,11 +58,6 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
|
|||
|
||||
namespace interfaces {
|
||||
|
||||
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
|
||||
{
|
||||
throw std::logic_error("Wallet function called in non-wallet build.");
|
||||
}
|
||||
|
||||
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
|
||||
{
|
||||
throw std::logic_error("Wallet function called in non-wallet build.");
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <vector>
|
||||
|
||||
class BanMan;
|
||||
class CCoinControl;
|
||||
class CFeeRate;
|
||||
class CNodeStats;
|
||||
class Coin;
|
||||
|
@ -36,6 +35,9 @@ struct bilingual_str;
|
|||
namespace node {
|
||||
struct NodeContext;
|
||||
} // namespace node
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
} // namespace wallet
|
||||
|
||||
namespace interfaces {
|
||||
class Handler;
|
||||
|
|
|
@ -23,19 +23,21 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class CCoinControl;
|
||||
class CFeeRate;
|
||||
class CKey;
|
||||
class CWallet;
|
||||
enum class FeeReason;
|
||||
enum class OutputType;
|
||||
enum class TransactionError;
|
||||
struct PartiallySignedTransaction;
|
||||
struct bilingual_str;
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
class CWallet;
|
||||
enum isminetype : unsigned int;
|
||||
struct CRecipient;
|
||||
struct PartiallySignedTransaction;
|
||||
struct WalletContext;
|
||||
struct bilingual_str;
|
||||
using isminefilter = std::underlying_type<isminetype>::type;
|
||||
} // namespace wallet
|
||||
|
||||
namespace interfaces {
|
||||
|
||||
|
@ -107,7 +109,7 @@ public:
|
|||
//! Look up address in wallet, return whether exists.
|
||||
virtual bool getAddress(const CTxDestination& dest,
|
||||
std::string* name,
|
||||
isminetype* is_mine,
|
||||
wallet::isminetype* is_mine,
|
||||
std::string* purpose) = 0;
|
||||
|
||||
//! Get wallet address list.
|
||||
|
@ -135,8 +137,8 @@ public:
|
|||
virtual void listLockedCoins(std::vector<COutPoint>& outputs) = 0;
|
||||
|
||||
//! Create transaction.
|
||||
virtual CTransactionRef createTransaction(const std::vector<CRecipient>& recipients,
|
||||
const CCoinControl& coin_control,
|
||||
virtual CTransactionRef createTransaction(const std::vector<wallet::CRecipient>& recipients,
|
||||
const wallet::CCoinControl& coin_control,
|
||||
bool sign,
|
||||
int& change_pos,
|
||||
CAmount& fee,
|
||||
|
@ -158,7 +160,7 @@ public:
|
|||
|
||||
//! Create bump transaction.
|
||||
virtual bool createBumpTransaction(const uint256& txid,
|
||||
const CCoinControl& coin_control,
|
||||
const wallet::CCoinControl& coin_control,
|
||||
std::vector<bilingual_str>& errors,
|
||||
CAmount& old_fee,
|
||||
CAmount& new_fee,
|
||||
|
@ -213,19 +215,19 @@ public:
|
|||
virtual CAmount getBalance() = 0;
|
||||
|
||||
//! Get available balance.
|
||||
virtual CAmount getAvailableBalance(const CCoinControl& coin_control) = 0;
|
||||
virtual CAmount getAvailableBalance(const wallet::CCoinControl& coin_control) = 0;
|
||||
|
||||
//! Return whether transaction input belongs to wallet.
|
||||
virtual isminetype txinIsMine(const CTxIn& txin) = 0;
|
||||
virtual wallet::isminetype txinIsMine(const CTxIn& txin) = 0;
|
||||
|
||||
//! Return whether transaction output belongs to wallet.
|
||||
virtual isminetype txoutIsMine(const CTxOut& txout) = 0;
|
||||
virtual wallet::isminetype txoutIsMine(const CTxOut& txout) = 0;
|
||||
|
||||
//! Return debit amount if transaction input belongs to wallet.
|
||||
virtual CAmount getDebit(const CTxIn& txin, isminefilter filter) = 0;
|
||||
virtual CAmount getDebit(const CTxIn& txin, wallet::isminefilter filter) = 0;
|
||||
|
||||
//! Return credit amount if transaction input belongs to wallet.
|
||||
virtual CAmount getCredit(const CTxOut& txout, isminefilter filter) = 0;
|
||||
virtual CAmount getCredit(const CTxOut& txout, wallet::isminefilter filter) = 0;
|
||||
|
||||
//! Return AvailableCoins + LockedCoins grouped by wallet address.
|
||||
//! (put change in one group with wallet address)
|
||||
|
@ -240,7 +242,7 @@ public:
|
|||
|
||||
//! Get minimum fee.
|
||||
virtual CAmount getMinimumFee(unsigned int tx_bytes,
|
||||
const CCoinControl& coin_control,
|
||||
const wallet::CCoinControl& coin_control,
|
||||
int* returned_target,
|
||||
FeeReason* reason) = 0;
|
||||
|
||||
|
@ -307,7 +309,7 @@ public:
|
|||
virtual std::unique_ptr<Handler> handleCanGetAddressesChanged(CanGetAddressesChangedFn fn) = 0;
|
||||
|
||||
//! Return pointer to internal wallet class, useful for testing.
|
||||
virtual CWallet* wallet() { return nullptr; }
|
||||
virtual wallet::CWallet* wallet() { return nullptr; }
|
||||
};
|
||||
|
||||
//! Wallet chain client that in addition to having chain client methods for
|
||||
|
@ -341,18 +343,18 @@ public:
|
|||
virtual std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) = 0;
|
||||
|
||||
//! Return pointer to internal context, useful for testing.
|
||||
virtual WalletContext* context() { return nullptr; }
|
||||
virtual wallet::WalletContext* context() { return nullptr; }
|
||||
};
|
||||
|
||||
//! Information about one wallet address.
|
||||
struct WalletAddress
|
||||
{
|
||||
CTxDestination dest;
|
||||
isminetype is_mine;
|
||||
wallet::isminetype is_mine;
|
||||
std::string name;
|
||||
std::string purpose;
|
||||
|
||||
WalletAddress(CTxDestination dest, isminetype is_mine, std::string name, std::string purpose)
|
||||
WalletAddress(CTxDestination dest, wallet::isminetype is_mine, std::string name, std::string purpose)
|
||||
: dest(std::move(dest)), is_mine(is_mine), name(std::move(name)), purpose(std::move(purpose))
|
||||
{
|
||||
}
|
||||
|
@ -382,10 +384,10 @@ struct WalletBalances
|
|||
struct WalletTx
|
||||
{
|
||||
CTransactionRef tx;
|
||||
std::vector<isminetype> txin_is_mine;
|
||||
std::vector<isminetype> txout_is_mine;
|
||||
std::vector<wallet::isminetype> txin_is_mine;
|
||||
std::vector<wallet::isminetype> txout_is_mine;
|
||||
std::vector<CTxDestination> txout_address;
|
||||
std::vector<isminetype> txout_address_is_mine;
|
||||
std::vector<wallet::isminetype> txout_address_is_mine;
|
||||
CAmount credit;
|
||||
CAmount debit;
|
||||
CAmount change;
|
||||
|
@ -420,7 +422,7 @@ struct WalletTxOut
|
|||
|
||||
//! Return implementation of Wallet interface. This function is defined in
|
||||
//! dummywallet.cpp and throws if the wallet component is not compiled.
|
||||
std::unique_ptr<Wallet> MakeWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
|
||||
std::unique_ptr<Wallet> MakeWallet(wallet::WalletContext& context, const std::shared_ptr<wallet::CWallet>& wallet);
|
||||
|
||||
//! Return implementation of ChainClient interface for a wallet loader. This
|
||||
//! function will be undefined in builds where ENABLE_WALLET is false.
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#include <QSettings>
|
||||
#include <QTreeWidget>
|
||||
|
||||
using wallet::CCoinControl;
|
||||
using wallet::MIN_CHANGE;
|
||||
|
||||
QList<CAmount> CoinControlDialog::payAmounts;
|
||||
bool CoinControlDialog::fSubtractFeeFromAmount = false;
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
class PlatformStyle;
|
||||
class WalletModel;
|
||||
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
} // namespace wallet
|
||||
|
||||
namespace Ui {
|
||||
class CoinControlDialog;
|
||||
|
@ -42,11 +44,11 @@ class CoinControlDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoinControlDialog(CCoinControl& coin_control, WalletModel* model, const PlatformStyle *platformStyle, QWidget *parent = nullptr);
|
||||
explicit CoinControlDialog(wallet::CCoinControl& coin_control, WalletModel* model, const PlatformStyle *platformStyle, QWidget *parent = nullptr);
|
||||
~CoinControlDialog();
|
||||
|
||||
// static because also called from sendcoinsdialog
|
||||
static void updateLabels(CCoinControl& m_coin_control, WalletModel*, QDialog*);
|
||||
static void updateLabels(wallet::CCoinControl& m_coin_control, WalletModel*, QDialog*);
|
||||
|
||||
static QList<CAmount> payAmounts;
|
||||
static bool fSubtractFeeFromAmount;
|
||||
|
@ -56,7 +58,7 @@ protected:
|
|||
|
||||
private:
|
||||
Ui::CoinControlDialog *ui;
|
||||
CCoinControl& m_coin_control;
|
||||
wallet::CCoinControl& m_coin_control;
|
||||
WalletModel *model;
|
||||
int sortColumn;
|
||||
Qt::SortOrder sortOrder;
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include <QSettings>
|
||||
#include <QTextDocument>
|
||||
|
||||
using wallet::CCoinControl;
|
||||
using wallet::DEFAULT_PAY_TX_FEE;
|
||||
|
||||
static constexpr std::array confTargets{2, 4, 6, 12, 24, 48, 144, 504, 1008};
|
||||
int getConfTargetForIndex(int index) {
|
||||
if (index+1 > static_cast<int>(confTargets.size())) {
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
class CCoinControl;
|
||||
class ClientModel;
|
||||
class PlatformStyle;
|
||||
class SendCoinsEntry;
|
||||
class SendCoinsRecipient;
|
||||
enum class SynchronizationState;
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
} // namespace wallet
|
||||
|
||||
namespace Ui {
|
||||
class SendCoinsDialog;
|
||||
|
@ -62,7 +64,7 @@ private:
|
|||
Ui::SendCoinsDialog *ui;
|
||||
ClientModel *clientModel;
|
||||
WalletModel *model;
|
||||
std::unique_ptr<CCoinControl> m_coin_control;
|
||||
std::unique_ptr<wallet::CCoinControl> m_coin_control;
|
||||
std::unique_ptr<WalletModelTransaction> m_current_transaction;
|
||||
bool fNewRecipientAllowed;
|
||||
bool fFeeMinimized;
|
||||
|
|
|
@ -24,6 +24,13 @@
|
|||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
|
||||
using wallet::AddWallet;
|
||||
using wallet::CWallet;
|
||||
using wallet::CreateMockWalletDatabase;
|
||||
using wallet::RemoveWallet;
|
||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||
using wallet::WalletContext;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
|
|
@ -39,6 +39,15 @@
|
|||
#include <QListView>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
using wallet::AddWallet;
|
||||
using wallet::CWallet;
|
||||
using wallet::CreateMockWalletDatabase;
|
||||
using wallet::RemoveWallet;
|
||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||
using wallet::WalletContext;
|
||||
using wallet::WalletDescriptor;
|
||||
using wallet::WalletRescanReserver;
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Press "Yes" or "Cancel" buttons in modal send confirmation dialog.
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
|
||||
#include <QLatin1String>
|
||||
|
||||
using wallet::ISMINE_ALL;
|
||||
using wallet::ISMINE_SPENDABLE;
|
||||
using wallet::ISMINE_WATCH_ONLY;
|
||||
using wallet::isminetype;
|
||||
|
||||
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
|
||||
{
|
||||
if (!status.is_final)
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
#include <QDateTime>
|
||||
|
||||
using wallet::ISMINE_SPENDABLE;
|
||||
using wallet::ISMINE_WATCH_ONLY;
|
||||
using wallet::isminetype;
|
||||
|
||||
/* Return positive answer if transaction should be shown in list.
|
||||
*/
|
||||
bool TransactionRecord::showTransaction()
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
|
||||
using wallet::WALLET_FLAG_BLANK_WALLET;
|
||||
using wallet::WALLET_FLAG_DESCRIPTORS;
|
||||
using wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS;
|
||||
using wallet::WALLET_FLAG_EXTERNAL_SIGNER;
|
||||
|
||||
WalletController::WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_activity_thread(new QThread(this))
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
using wallet::CCoinControl;
|
||||
using wallet::CRecipient;
|
||||
using wallet::DEFAULT_DISABLE_WALLET;
|
||||
|
||||
WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel& client_model, const PlatformStyle *platformStyle, QObject *parent) :
|
||||
QObject(parent),
|
||||
|
|
|
@ -32,16 +32,17 @@ class SendCoinsRecipient;
|
|||
class TransactionTableModel;
|
||||
class WalletModelTransaction;
|
||||
|
||||
class CCoinControl;
|
||||
class CKeyID;
|
||||
class COutPoint;
|
||||
class COutput;
|
||||
class CPubKey;
|
||||
class uint256;
|
||||
|
||||
namespace interfaces {
|
||||
class Node;
|
||||
} // namespace interfaces
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
} // namespace wallet
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTimer;
|
||||
|
@ -99,7 +100,7 @@ public:
|
|||
};
|
||||
|
||||
// prepare transaction for getting txfee before sending coins
|
||||
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl& coinControl);
|
||||
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const wallet::CCoinControl& coinControl);
|
||||
|
||||
// Send coins to a list of recipients
|
||||
SendCoinsReturn sendCoins(WalletModelTransaction &transaction);
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
extern const std::function<void(const std::string&)> G_TEST_LOG_FUN;
|
||||
|
||||
// Enable BOOST_CHECK_EQUAL for enum class types
|
||||
namespace std {
|
||||
template <typename T>
|
||||
std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
|
||||
{
|
||||
return stream << static_cast<typename std::underlying_type<T>::type>(e);
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
/**
|
||||
* This global and the helpers that use it are not thread-safe.
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <wallet/wallet.h>
|
||||
#endif
|
||||
|
||||
using wallet::CWallet;
|
||||
|
||||
const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj";
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
} // namespace wallet
|
||||
|
||||
// Constants //
|
||||
|
||||
|
@ -16,9 +18,9 @@ extern const std::string ADDRESS_BCRT1_UNSPENDABLE;
|
|||
// RPC-like //
|
||||
|
||||
/** Import the address to the wallet */
|
||||
void importaddress(CWallet& wallet, const std::string& address);
|
||||
void importaddress(wallet::CWallet& wallet, const std::string& address);
|
||||
/** Returns a new address from the wallet */
|
||||
std::string getnewaddress(CWallet& w);
|
||||
std::string getnewaddress(wallet::CWallet& w);
|
||||
|
||||
|
||||
#endif // BITCOIN_TEST_UTIL_WALLET_H
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
namespace wallet {
|
||||
namespace {
|
||||
|
||||
//! Make sure database has a unique fileid within the environment. If it
|
||||
|
@ -846,3 +847,4 @@ std::unique_ptr<BerkeleyDatabase> MakeBerkeleyDatabase(const fs::path& path, con
|
|||
status = DatabaseStatus::SUCCESS;
|
||||
return db;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100;
|
||||
static const bool DEFAULT_WALLET_PRIVDB = true;
|
||||
|
||||
|
@ -229,5 +230,6 @@ bool BerkeleyDatabaseSanityCheck();
|
|||
|
||||
//! Return object giving access to Berkeley database at specified path.
|
||||
std::unique_ptr<BerkeleyDatabase> MakeBerkeleyDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_BDB_H
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
|
||||
#include <util/system.h>
|
||||
|
||||
namespace wallet {
|
||||
CCoinControl::CCoinControl()
|
||||
{
|
||||
m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS);
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace wallet {
|
||||
const int DEFAULT_MIN_DEPTH = 0;
|
||||
const int DEFAULT_MAX_DEPTH = 9999999;
|
||||
|
||||
|
@ -118,5 +119,6 @@ private:
|
|||
std::set<COutPoint> setSelected;
|
||||
std::map<COutPoint, CTxOut> m_external_txouts;
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_COINCONTROL_H
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <numeric>
|
||||
#include <optional>
|
||||
|
||||
namespace wallet {
|
||||
// Descending order comparator
|
||||
struct {
|
||||
bool operator()(const OutputGroup& a, const OutputGroup& b) const
|
||||
|
@ -429,3 +430,4 @@ bool SelectionResult::operator<(SelectionResult other) const
|
|||
// As this operator is only used in std::min_element, we want the result that has more inputs when waste are equal.
|
||||
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <optional>
|
||||
|
||||
namespace wallet {
|
||||
//! target minimum change amount
|
||||
static constexpr CAmount MIN_CHANGE{COIN / 100};
|
||||
//! final minimum change amount after paying for fees
|
||||
|
@ -249,5 +250,6 @@ std::optional<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& ut
|
|||
|
||||
// Original coin selection algorithm as a fallback
|
||||
std::optional<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_COINSELECTION_H
|
||||
|
|
|
@ -4,5 +4,7 @@
|
|||
|
||||
#include <wallet/context.h>
|
||||
|
||||
namespace wallet {
|
||||
WalletContext::WalletContext() {}
|
||||
WalletContext::~WalletContext() {}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
class CWallet;
|
||||
namespace interfaces {
|
||||
class Chain;
|
||||
class Wallet;
|
||||
} // namespace interfaces
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
|
||||
|
||||
//! WalletContext struct containing references to state shared between CWallet
|
||||
|
@ -46,5 +47,6 @@ struct WalletContext {
|
|||
WalletContext();
|
||||
~WalletContext();
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_CONTEXT_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
int CCrypter::BytesToKeySHA512AES(const std::vector<unsigned char>& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const
|
||||
{
|
||||
// This mimics the behavior of openssl's EVP_BytesToKey with an aes256cbc
|
||||
|
@ -136,3 +137,4 @@ bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector<unsigned ch
|
|||
key.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed());
|
||||
return key.VerifyPubKey(vchPubKey);
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <script/signingprovider.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
|
||||
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
|
||||
const unsigned int WALLET_CRYPTO_IV_SIZE = 16;
|
||||
|
@ -105,5 +106,6 @@ public:
|
|||
bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector<unsigned char> &vchCiphertext);
|
||||
bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector<unsigned char>& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext);
|
||||
bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector<unsigned char>& vchCryptedSecret, const CPubKey& vchPubKey, CKey& key);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_CRYPTER_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace wallet {
|
||||
std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
|
||||
{
|
||||
std::vector<fs::path> paths;
|
||||
|
@ -132,3 +133,4 @@ bool IsSQLiteFile(const fs::path& path)
|
|||
// Check the application id matches our network magic
|
||||
return memcmp(Params().MessageStart(), app_id, 4) == 0;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename);
|
||||
|
||||
/** RAII class that provides access to a WalletDatabase */
|
||||
|
@ -232,5 +233,6 @@ fs::path BDBDataFile(const fs::path& path);
|
|||
fs::path SQLiteDataFile(const fs::path& path);
|
||||
bool IsBDBFile(const fs::path& path);
|
||||
bool IsSQLiteFile(const fs::path& path);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_DB_H
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <util/translation.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
namespace wallet {
|
||||
static const std::string DUMP_MAGIC = "BITCOIN_CORE_WALLET_DUMP";
|
||||
uint32_t DUMP_VERSION = 1;
|
||||
|
||||
|
@ -284,3 +285,4 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling
|
|||
|
||||
return ret;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
#include <fs.h>
|
||||
|
||||
class CWallet;
|
||||
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
bool DumpWallet(CWallet& wallet, bilingual_str& error);
|
||||
bool CreateFromDump(const std::string& name, const fs::path& wallet_path, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_DUMP_H
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
bool ExternalSignerScriptPubKeyMan::SetupDescriptor(std::unique_ptr<Descriptor> desc)
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
|
@ -82,3 +83,4 @@ TransactionError ExternalSignerScriptPubKeyMan::FillPSBT(PartiallySignedTransact
|
|||
if (finalize) FinalizePSBT(psbt); // This won't work in a multisig setup
|
||||
return TransactionError::OK;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace wallet {
|
||||
class ExternalSignerScriptPubKeyMan : public DescriptorScriptPubKeyMan
|
||||
{
|
||||
public:
|
||||
|
@ -30,4 +31,5 @@ class ExternalSignerScriptPubKeyMan : public DescriptorScriptPubKeyMan
|
|||
|
||||
TransactionError FillPSBT(PartiallySignedTransaction& psbt, const PrecomputedTransactionData& txdata, int sighash_type = 1 /* SIGHASH_ALL */, bool sign = true, bool bip32derivs = false, int* n_signed = nullptr, bool finalize = true) const override;
|
||||
};
|
||||
} // namespace wallet
|
||||
#endif // BITCOIN_WALLET_EXTERNAL_SIGNER_SCRIPTPUBKEYMAN_H
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <wallet/spend.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
namespace wallet {
|
||||
//! Check whether transaction has descendant in wallet or mempool, or has been
|
||||
//! mined, or conflicts with a mined transaction. Return a feebumper::Result.
|
||||
static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
|
||||
|
@ -282,3 +283,4 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti
|
|||
}
|
||||
|
||||
} // namespace feebumper
|
||||
} // namespace wallet
|
||||
|
|
|
@ -7,13 +7,15 @@
|
|||
|
||||
#include <primitives/transaction.h>
|
||||
|
||||
class CWallet;
|
||||
class CWalletTx;
|
||||
class uint256;
|
||||
class CCoinControl;
|
||||
enum class FeeEstimateMode;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
class CWallet;
|
||||
class CWalletTx;
|
||||
|
||||
namespace feebumper {
|
||||
|
||||
enum class Result
|
||||
|
@ -54,5 +56,6 @@ Result CommitTransaction(CWallet& wallet,
|
|||
uint256& bumped_txid);
|
||||
|
||||
} // namespace feebumper
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_FEEBUMPER_H
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
CAmount GetRequiredFee(const CWallet& wallet, unsigned int nTxBytes)
|
||||
{
|
||||
return GetRequiredFeeRate(wallet).GetFee(nTxBytes);
|
||||
|
@ -90,3 +91,4 @@ CFeeRate GetDiscardRate(const CWallet& wallet)
|
|||
discard_rate = std::max(discard_rate, wallet.chain().relayDustFee());
|
||||
return discard_rate;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
|
||||
#include <consensus/amount.h>
|
||||
|
||||
class CCoinControl;
|
||||
class CFeeRate;
|
||||
class CWallet;
|
||||
struct FeeCalculation;
|
||||
|
||||
namespace wallet {
|
||||
class CCoinControl;
|
||||
class CWallet;
|
||||
|
||||
/**
|
||||
* Return the minimum required absolute fee for this size
|
||||
* based on the required fee rate
|
||||
|
@ -41,5 +43,6 @@ CFeeRate GetMinimumFeeRate(const CWallet& wallet, const CCoinControl& coin_contr
|
|||
* Return the maximum feerate for discarding change.
|
||||
*/
|
||||
CFeeRate GetDiscardRate(const CWallet& wallet);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_FEES_H
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
using node::NodeContext;
|
||||
|
||||
namespace wallet {
|
||||
class WalletInit : public WalletInitInterface
|
||||
{
|
||||
public:
|
||||
|
@ -41,8 +42,6 @@ public:
|
|||
void Construct(NodeContext& node) const override;
|
||||
};
|
||||
|
||||
const WalletInitInterface& g_wallet_init_interface = WalletInit();
|
||||
|
||||
void WalletInit::AddWalletOptions(ArgsManager& argsman) const
|
||||
{
|
||||
argsman.AddArg("-addresstype", strprintf("What type of addresses to use (\"legacy\", \"p2sh-segwit\", \"bech32\", or \"bech32m\", default: \"%s\")", FormatOutputType(DEFAULT_ADDRESS_TYPE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
|
@ -139,3 +138,6 @@ void WalletInit::Construct(NodeContext& node) const
|
|||
node.wallet_loader = wallet_loader.get();
|
||||
node.chain_clients.emplace_back(std::move(wallet_loader));
|
||||
}
|
||||
} // namespace wallet
|
||||
|
||||
const WalletInitInterface& g_wallet_init_interface = wallet::WalletInit();
|
||||
|
|
|
@ -598,7 +598,7 @@ public:
|
|||
} // namespace wallet
|
||||
|
||||
namespace interfaces {
|
||||
std::unique_ptr<Wallet> MakeWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(context, wallet) : nullptr; }
|
||||
std::unique_ptr<Wallet> MakeWallet(wallet::WalletContext& context, const std::shared_ptr<wallet::CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(context, wallet) : nullptr; }
|
||||
|
||||
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
|
||||
{
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
class CWallet;
|
||||
class CScript;
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
|
||||
/**
|
||||
* IsMine() return codes, which depend on ScriptPubKeyMan implementation.
|
||||
* Not every ScriptPubKeyMan covers all types, please refer to
|
||||
|
@ -66,5 +68,6 @@ struct CachableAmount
|
|||
m_value[filter] = value;
|
||||
}
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_ISMINE_H
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <univalue.h>
|
||||
|
||||
namespace wallet {
|
||||
bool VerifyWallets(WalletContext& context)
|
||||
{
|
||||
interfaces::Chain& chain = *context.chain;
|
||||
|
@ -169,3 +170,4 @@ void UnloadWallets(WalletContext& context)
|
|||
UnloadWallet(std::move(wallet));
|
||||
}
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
|
||||
class ArgsManager;
|
||||
class CScheduler;
|
||||
struct WalletContext;
|
||||
|
||||
namespace interfaces {
|
||||
class Chain;
|
||||
} // namespace interfaces
|
||||
|
||||
namespace wallet {
|
||||
struct WalletContext;
|
||||
|
||||
//! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
|
||||
bool VerifyWallets(WalletContext& context);
|
||||
|
||||
|
@ -34,5 +36,6 @@ void StopWallets(WalletContext& context);
|
|||
|
||||
//! Close all wallets.
|
||||
void UnloadWallets(WalletContext& context);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_LOAD_H
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <wallet/transaction.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
namespace wallet {
|
||||
isminetype InputIsMine(const CWallet& wallet, const CTxIn &txin)
|
||||
{
|
||||
AssertLockHeld(wallet.cs_wallet);
|
||||
|
@ -473,3 +474,4 @@ std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet)
|
|||
|
||||
return ret;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <wallet/transaction.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
namespace wallet {
|
||||
isminetype InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
|
||||
/** Returns whether all of the inputs match the filter */
|
||||
|
@ -60,5 +61,6 @@ Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse =
|
|||
|
||||
std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
|
||||
std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_RECEIVE_H
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <univalue.h>
|
||||
|
||||
namespace wallet {
|
||||
RPCHelpMan getnewaddress()
|
||||
{
|
||||
return RPCHelpMan{"getnewaddress",
|
||||
|
@ -802,3 +803,4 @@ RPCHelpMan walletdisplayaddress()
|
|||
};
|
||||
}
|
||||
#endif // ENABLE_EXTERNAL_SIGNER
|
||||
} // namespace wallet
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
using interfaces::FoundBlock;
|
||||
|
||||
namespace wallet {
|
||||
std::string static EncodeDumpString(const std::string &str) {
|
||||
std::stringstream ret;
|
||||
for (const unsigned char c : str) {
|
||||
|
@ -1900,3 +1901,4 @@ RPCHelpMan restorewallet()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <univalue.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
static CAmount GetReceived(const CWallet& wallet, const UniValue& params, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
|
||||
{
|
||||
std::set<CTxDestination> address_set;
|
||||
|
@ -731,3 +732,4 @@ RPCHelpMan listunspent()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
RPCHelpMan walletpassphrase()
|
||||
{
|
||||
return RPCHelpMan{"walletpassphrase",
|
||||
|
@ -246,3 +247,4 @@ RPCHelpMan encryptwallet()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <univalue.h>
|
||||
|
||||
namespace wallet {
|
||||
RPCHelpMan signmessage()
|
||||
{
|
||||
return RPCHelpMan{"signmessage",
|
||||
|
@ -66,3 +67,4 @@ RPCHelpMan signmessage()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <univalue.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
static void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs, std::vector<CRecipient> &recipients) {
|
||||
std::set<CTxDestination> destinations;
|
||||
int i = 0;
|
||||
|
@ -1367,3 +1368,4 @@ RPCHelpMan walletcreatefundedpsbt()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
using interfaces::FoundBlock;
|
||||
|
||||
namespace wallet {
|
||||
static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue& entry)
|
||||
{
|
||||
interfaces::Chain& chain = wallet.chain();
|
||||
|
@ -958,3 +959,4 @@ RPCHelpMan abortrescan()
|
|||
},
|
||||
};
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <univalue.h>
|
||||
|
||||
namespace wallet {
|
||||
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
|
||||
const std::string HELP_REQUIRING_PASSPHRASE{"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
|
||||
|
||||
|
@ -147,4 +148,5 @@ void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& st
|
|||
}
|
||||
throw JSONRPCError(code, error.original);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct bilingual_str;
|
||||
class CWallet;
|
||||
enum class DatabaseStatus;
|
||||
class JSONRPCRequest;
|
||||
class LegacyScriptPubKeyMan;
|
||||
class UniValue;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
class LegacyScriptPubKeyMan;
|
||||
enum class DatabaseStatus;
|
||||
struct WalletContext;
|
||||
|
||||
extern const std::string HELP_REQUIRING_PASSPHRASE;
|
||||
|
@ -39,5 +41,6 @@ bool ParseIncludeWatchonly(const UniValue& include_watchonly, const CWallet& wal
|
|||
std::string LabelFromValue(const UniValue& value);
|
||||
|
||||
void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_RPC_UTIL_H
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <univalue.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
/** Checks if a CKey is in the given CWallet compressed or otherwise*/
|
||||
bool HaveKey(const SigningProvider& wallet, const CKey& key)
|
||||
{
|
||||
|
@ -729,3 +730,4 @@ static const CRPCCommand commands[] =
|
|||
// clang-format on
|
||||
return commands;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
class CRPCCommand;
|
||||
|
||||
namespace wallet {
|
||||
Span<const CRPCCommand> GetWalletRPCCommands();
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_RPC_WALLET_H
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
#include <wallet/walletdb.h>
|
||||
|
||||
namespace wallet {
|
||||
/* End of headers, beginning of key/value data */
|
||||
static const char *HEADER_END = "HEADER=END";
|
||||
/* End of key/value data */
|
||||
|
@ -165,3 +166,4 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
|
|||
|
||||
return fSuccess;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_SALVAGE_H
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <optional>
|
||||
|
||||
namespace wallet {
|
||||
//! Value for the first BIP 32 hardened derivation. Can be used as a bit mask and as a value. See BIP 32 for more details.
|
||||
const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000;
|
||||
|
||||
|
@ -2359,3 +2360,4 @@ bool DescriptorScriptPubKeyMan::CanUpdateToWalletDescriptor(const WalletDescript
|
|||
|
||||
return true;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
enum class OutputType;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
// Wallet storage things that ScriptPubKeyMans need in order to be able to store things to the wallet database.
|
||||
// It provides access to things that are part of the entire wallet and not specific to a ScriptPubKeyMan such as
|
||||
// wallet flags, wallet version, encryption keys, encryption status, and the database itself. This allows a
|
||||
|
@ -631,5 +632,6 @@ public:
|
|||
|
||||
void UpgradeDescriptorCache();
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_SCRIPTPUBKEYMAN_H
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
using interfaces::FoundBlock;
|
||||
|
||||
namespace wallet {
|
||||
static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100};
|
||||
|
||||
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig)
|
||||
|
@ -1030,3 +1031,4 @@ bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet,
|
|||
|
||||
return true;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <wallet/transaction.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
namespace wallet {
|
||||
/** Get the marginal bytes if spending the specified output from this transaction */
|
||||
int GetTxSpendSize(const CWallet& wallet, const CWalletTx& wtx, unsigned int out, bool use_max_sig = false);
|
||||
|
||||
|
@ -142,5 +143,6 @@ bool CreateTransaction(CWallet& wallet, const std::vector<CRecipient>& vecSend,
|
|||
* calling CreateTransaction();
|
||||
*/
|
||||
bool FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_SPEND_H
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
static constexpr int32_t WALLET_SCHEMA_VERSION = 0;
|
||||
|
||||
static Mutex g_sqlite_mutex;
|
||||
|
@ -578,3 +579,4 @@ std::string SQLiteDatabaseVersion()
|
|||
{
|
||||
return std::string(sqlite3_libversion());
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <sqlite3.h>
|
||||
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
class SQLiteDatabase;
|
||||
|
||||
/** RAII class that provides access to a WalletDatabase */
|
||||
|
@ -116,5 +118,6 @@ public:
|
|||
std::unique_ptr<SQLiteDatabase> MakeSQLiteDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
|
||||
|
||||
std::string SQLiteDatabaseVersion();
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_SQLITE_H
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
#include <random>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(coinselector_tests, WalletTestingSetup)
|
||||
|
||||
// how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles
|
||||
|
@ -807,3 +808,4 @@ BOOST_AUTO_TEST_CASE(waste_test)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wallet/bdb.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(db_tests, BasicTestingSetup)
|
||||
|
||||
static std::shared_ptr<BerkeleyEnvironment> GetWalletEnv(const fs::path& path, std::string& database_filename)
|
||||
|
@ -77,3 +78,4 @@ BOOST_AUTO_TEST_CASE(getwalletenv_g_dbenvs_free_instance)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
namespace {
|
||||
const TestingSetup* g_setup;
|
||||
|
||||
|
@ -168,3 +169,4 @@ FUZZ_TARGET_INIT(wallet_notifications, initialize_setup)
|
|||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace wallet
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <wallet/test/init_test_fixture.h>
|
||||
|
||||
namespace wallet {
|
||||
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
|
||||
{
|
||||
m_wallet_loader = MakeWalletLoader(*m_node.chain, *Assert(m_node.args));
|
||||
|
@ -48,3 +49,4 @@ void InitWalletDirTestingSetup::SetWalletDir(const fs::path& walletdir_path)
|
|||
{
|
||||
gArgs.ForceSetArg("-walletdir", fs::PathToString(walletdir_path));
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <test/util/setup_common.h>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
||||
explicit InitWalletDirTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
|
||||
~InitWalletDirTestingSetup();
|
||||
|
@ -23,3 +24,4 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
|
|||
};
|
||||
|
||||
#endif // BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <util/system.h>
|
||||
#include <wallet/test/init_test_fixture.h>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(init_tests, InitWalletDirTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default)
|
||||
|
@ -83,3 +84,4 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(ismine_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ismine_standard)
|
||||
|
@ -417,3 +418,4 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <test/util/setup_common.h>
|
||||
#include <wallet/test/wallet_test_fixture.h>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(psbt_wallet_tests, WalletTestingSetup)
|
||||
|
||||
static void import_descriptor(CWallet& wallet, const std::string& descriptor)
|
||||
|
@ -145,3 +146,4 @@ BOOST_AUTO_TEST_CASE(parse_hd_keypath)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
|
||||
|
||||
// Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true
|
||||
|
@ -39,3 +40,4 @@ BOOST_AUTO_TEST_CASE(CanProvide)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(spend_tests, WalletTestingSetup)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
|
||||
|
@ -63,3 +64,4 @@ BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace wallet {
|
||||
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key)
|
||||
{
|
||||
auto wallet = std::make_unique<CWallet>(&chain, "", args, CreateMockWalletDatabase());
|
||||
|
@ -44,3 +45,4 @@ std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cc
|
|||
BOOST_CHECK(result.last_failed_block.IsNull());
|
||||
return wallet;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,11 +10,14 @@
|
|||
class ArgsManager;
|
||||
class CChain;
|
||||
class CKey;
|
||||
class CWallet;
|
||||
namespace interfaces {
|
||||
class Chain;
|
||||
} // namespace interfaces
|
||||
|
||||
namespace wallet {
|
||||
class CWallet;
|
||||
|
||||
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_TEST_UTIL_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(wallet_crypto_tests, BasicTestingSetup)
|
||||
|
||||
class TestCrypter
|
||||
|
@ -124,3 +125,4 @@ BOOST_AUTO_TEST_CASE(decrypt) {
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <scheduler.h>
|
||||
|
||||
namespace wallet {
|
||||
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
|
||||
: TestingSetup(chainName),
|
||||
m_wallet(m_node.chain.get(), "", m_args, CreateMockWalletDatabase())
|
||||
|
@ -19,3 +20,4 @@ WalletTestingSetup::~WalletTestingSetup()
|
|||
{
|
||||
if (m_node.scheduler) m_node.scheduler->stop();
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace wallet {
|
||||
/** Testing setup and teardown for wallet.
|
||||
*/
|
||||
struct WalletTestingSetup : public TestingSetup {
|
||||
|
@ -25,5 +26,6 @@ struct WalletTestingSetup : public TestingSetup {
|
|||
CWallet m_wallet;
|
||||
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_TEST_WALLET_TEST_FIXTURE_H
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
using node::MAX_BLOCKFILE_SIZE;
|
||||
using node::UnlinkPrunedFiles;
|
||||
|
||||
namespace wallet {
|
||||
RPCHelpMan importmulti();
|
||||
RPCHelpMan dumpwallet();
|
||||
RPCHelpMan importwallet();
|
||||
|
@ -292,7 +293,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
|||
request.params.setArray();
|
||||
request.params.push_back(backup_file);
|
||||
|
||||
::dumpwallet().HandleRequest(request);
|
||||
wallet::dumpwallet().HandleRequest(request);
|
||||
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
|
||||
}
|
||||
|
||||
|
@ -311,7 +312,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
|||
request.params.push_back(backup_file);
|
||||
AddWallet(context, wallet);
|
||||
wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
|
||||
::importwallet().HandleRequest(request);
|
||||
wallet::importwallet().HandleRequest(request);
|
||||
RemoveWallet(context, wallet, /* load_on_start= */ std::nullopt);
|
||||
|
||||
BOOST_CHECK_EQUAL(wallet->mapWallet.size(), 3U);
|
||||
|
@ -854,3 +855,4 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(wallet_transaction_tests, WalletTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(roundtrip)
|
||||
|
@ -22,3 +23,4 @@ BOOST_AUTO_TEST_CASE(roundtrip)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(walletdb_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)
|
||||
|
@ -27,3 +28,4 @@ BOOST_AUTO_TEST_CASE(walletdb_readkeyvalue)
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <wallet/transaction.h>
|
||||
|
||||
namespace wallet {
|
||||
bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
|
||||
{
|
||||
CMutableTransaction tx1 {*this->tx};
|
||||
|
@ -23,3 +24,4 @@ int64_t CWalletTx::GetTxTime() const
|
|||
int64_t n = nTimeSmart;
|
||||
return n ? n : nTimeReceived;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
//! State of transaction confirmed in a block.
|
||||
struct TxStateConfirmed {
|
||||
uint256 confirmed_block_hash;
|
||||
|
@ -303,5 +304,6 @@ public:
|
|||
CWalletTx(CWalletTx const &) = delete;
|
||||
void operator=(CWalletTx const &x) = delete;
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_TRANSACTION_H
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
using interfaces::FoundBlock;
|
||||
|
||||
namespace wallet {
|
||||
const std::map<uint64_t,std::string> WALLET_FLAG_CAVEATS{
|
||||
{WALLET_FLAG_AVOID_REUSE,
|
||||
"You need to rescan the blockchain in order to correctly mark used "
|
||||
|
@ -3433,3 +3434,4 @@ ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const Flat
|
|||
|
||||
return spk_man;
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -40,12 +40,17 @@
|
|||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
struct WalletContext;
|
||||
|
||||
using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wallet)>;
|
||||
|
||||
class CScript;
|
||||
enum class FeeEstimateMode;
|
||||
struct FeeCalculation;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace wallet {
|
||||
struct WalletContext;
|
||||
|
||||
//! Explicitly unload and delete the wallet.
|
||||
//! Blocks the current thread after signaling the unload intent so that all
|
||||
//! wallet pointer owners release the wallet.
|
||||
|
@ -107,10 +112,7 @@ static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
|
|||
|
||||
class CCoinControl;
|
||||
class COutput;
|
||||
class CScript;
|
||||
class CWalletTx;
|
||||
struct FeeCalculation;
|
||||
enum class FeeEstimateMode;
|
||||
class ReserveDestination;
|
||||
|
||||
//! Default for -addresstype
|
||||
|
@ -936,5 +938,6 @@ bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
|
|||
bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name);
|
||||
|
||||
bool DummySignInput(const SigningProvider& provider, CTxIn &tx_in, const CTxOut &txout, bool use_max_sig);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLET_H
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace wallet {
|
||||
namespace DBKeys {
|
||||
const std::string ACENTRY{"acentry"};
|
||||
const std::string ACTIVEEXTERNALSPK{"activeexternalspk"};
|
||||
|
@ -1194,3 +1195,4 @@ std::unique_ptr<WalletDatabase> CreateMockWalletDatabase()
|
|||
return std::make_unique<BerkeleyDatabase>(std::make_shared<BerkeleyEnvironment>(), "");
|
||||
#endif
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -15,6 +15,18 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CScript;
|
||||
class uint160;
|
||||
class uint256;
|
||||
struct CBlockLocator;
|
||||
|
||||
namespace wallet {
|
||||
class CKeyPool;
|
||||
class CMasterKey;
|
||||
class CWallet;
|
||||
class CWalletTx;
|
||||
struct WalletContext;
|
||||
|
||||
/**
|
||||
* Overview of wallet database classes:
|
||||
*
|
||||
|
@ -29,16 +41,6 @@
|
|||
|
||||
static const bool DEFAULT_FLUSHWALLET = true;
|
||||
|
||||
struct CBlockLocator;
|
||||
struct WalletContext;
|
||||
class CKeyPool;
|
||||
class CMasterKey;
|
||||
class CScript;
|
||||
class CWallet;
|
||||
class CWalletTx;
|
||||
class uint160;
|
||||
class uint256;
|
||||
|
||||
/** Error statuses for the wallet database */
|
||||
enum class DBErrors
|
||||
{
|
||||
|
@ -297,5 +299,6 @@ std::unique_ptr<WalletDatabase> CreateDummyWalletDatabase();
|
|||
|
||||
/** Return object for accessing temporary in-memory database. */
|
||||
std::unique_ptr<WalletDatabase> CreateMockWalletDatabase();
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLETDB_H
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <wallet/wallet.h>
|
||||
#include <wallet/walletutil.h>
|
||||
|
||||
namespace wallet {
|
||||
namespace WalletTool {
|
||||
|
||||
// The standard wallet deleter function blocks on the validation interface
|
||||
|
@ -219,3 +220,4 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
|||
return true;
|
||||
}
|
||||
} // namespace WalletTool
|
||||
} // namespace wallet
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
|
||||
class ArgsManager;
|
||||
|
||||
namespace wallet {
|
||||
namespace WalletTool {
|
||||
|
||||
bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command);
|
||||
|
||||
} // namespace WalletTool
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLETTOOL_H
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <logging.h>
|
||||
#include <util/system.h>
|
||||
|
||||
namespace wallet {
|
||||
fs::path GetWalletDir()
|
||||
{
|
||||
fs::path path;
|
||||
|
@ -42,3 +43,4 @@ WalletFeature GetClosestWalletFeature(int version)
|
|||
}
|
||||
return static_cast<WalletFeature>(0);
|
||||
}
|
||||
} // namespace wallet
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace wallet {
|
||||
/** (client) version numbers for particular wallet features */
|
||||
enum WalletFeature
|
||||
{
|
||||
|
@ -103,5 +104,6 @@ public:
|
|||
WalletDescriptor() {}
|
||||
WalletDescriptor(std::shared_ptr<Descriptor> descriptor, uint64_t creation_time, int32_t range_start, int32_t range_end, int32_t next_index) : descriptor(descriptor), creation_time(creation_time), range_start(range_start), range_end(range_end), next_index(next_index) {}
|
||||
};
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLETUTIL_H
|
||||
|
|
Loading…
Add table
Reference in a new issue