29#include <validation.h>
36#include <QAbstractButton>
38#include <QApplication>
47#include <QDialogButtonBox>
66 if (
widget->inherits(
"SendConfirmationDialog")) {
68 if (text) *text =
dialog->text();
79 QMessageBox::StandardButton
confirm_type = QMessageBox::Yes)
85 sendCoinsDialog.findChild<QFrame*>(
"frameFee")
90 boost::signals2::scoped_connection
c(
wallet.NotifyTransactionChanged.connect([&txid](
const Txid& hash,
ChangeType status) {
91 if (status == CT_NEW) txid = hash;
94 bool invoked = QMetaObject::invokeMethod(&sendCoinsDialog,
"sendButtonClicked",
Q_ARG(
bool,
false));
103 int rows = model.rowCount({});
117 QModelIndex index = FindTx(*table->selectionModel()->model(), txid);
118 QVERIFY2(index.isValid(),
"Could not find BumpFee txid");
123 table->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
125 table->customContextMenuRequested({});
155 QVERIFY(entries->count() == 1);
169 for (
const auto& [outpoint,
tx_out] : coins.begin()->
second) {
186 CWallet::ScanResult result =
wallet->ScanForWalletTransactions(
Params().GetConsensus().hashGenesisBlock, 0, {},
reserver,
true,
false);
188 QCOMPARE(result.last_scanned_block,
WITH_LOCK(
node.context()->chainman->GetMutex(),
return node.context()->chainman->ActiveChain().Tip()->GetBlockHash()));
189 QVERIFY(result.last_failed_block.IsNull());
194 std::shared_ptr<CWallet>
wallet = std::make_shared<CWallet>(
node.context()->chain.get(),
"", CreateMockableWalletDatabase());
196 wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
198 wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
200 wallet->SetupDescriptorScriptPubKeyMans();
215 auto& desc =
descs.at(0);
220 wallet->SetLastBlockProcessed(105,
WITH_LOCK(
node.context()->chainman->GetMutex(),
return node.context()->chainman->ActiveChain().Tip()->GetBlockHash()));
222 wallet->SetBroadcastTransactions(
true);
231 std::unique_ptr<ClientModel> clientModel;
232 std::unique_ptr<WalletModel> walletModel;
237 clientModel = std::make_unique<ClientModel>(
node, &optionsModel);
243 AddWallet(context,
wallet);
245 RemoveWallet(context,
wallet, std::nullopt);
246 sendCoinsDialog.
setModel(walletModel.get());
247 transactionView.
setModel(walletModel.get());
289 qApp->processEvents();
291 QVERIFY(FindTx(*transactionTableModel,
txid1).isValid());
292 QVERIFY(FindTx(*transactionTableModel,
txid2).isValid());
298 BumpFee(transactionView,
txid2,
true,
"already bumped",
false);
302 overviewPage.setWalletModel(&walletModel);
327 if (
widget->inherits(
"ReceiveRequestDialog")) {
404 sendCoinsDialog.findChild<QLabel*>(
"labelBalance"));
411 timer.setInterval(500);
412 QObject::connect(&timer, &QTimer::timeout, [&](){
414 if (
widget->inherits(
"QMessageBox") &&
widget->objectName().compare(
"psbt_copied_message") == 0) {
428 const std::string&
psbt_string = QApplication::clipboard()->text().toStdString();
443 for (
int i = 0; i < 5; ++i) {
464 if (QApplication::platformName() ==
"minimal") {
469 qWarning() <<
"Skipping WalletTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
470 "with 'QT_QPA_PLATFORM=cocoa test_bitcoin-qt' on mac, or else use a linux or windows build.";
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Widget for entering bitcoin amounts.
void setValue(const CAmount &value)
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
CPubKey GetPubKey() const
Compute the public key from a private key.
Interface from Qt to configuration data structure for Bitcoin client.
bool Init(bilingual_str &error)
BitcoinUnit getDisplayUnit() const
Overview ("home") page widget.
Line edit that can be marked as "invalid" to show input validation feedback.
Dialog for requesting payment of bitcoins.
SendCoinsRecipient recipient
Model for list of recently generated payment requests / bitcoin: URIs.
Dialog for sending bitcoins.
void setModel(WalletModel *model)
wallet::CCoinControl * getCoinControl()
A single entry in the dialog for sending bitcoins.
std::string sPaymentRequest
QString authenticatedMerchant
Minimal stream for reading from an existing byte array by std::span.
UI model for the transaction table of a wallet.
@ TxHashRole
Transaction hash.
int rowCount(const QModelIndex &parent) const override
Widget showing the transaction list for a wallet, including a filter row.
void setModel(WalletModel *model)
QTableView * transactionView
Interface to Bitcoin wallet from Qt view code.
RecentRequestsTableModel * getRecentRequestsTableModel() const
void pollBalanceChanged()
TransactionTableModel * getTransactionTableModel() const
interfaces::Wallet & wallet() const
OptionsModel * getOptionsModel() const
interfaces::WalletBalances getCachedBalance() const
interfaces::Node & m_node
Top-level interface for a bitcoin node (bitcoind process).
virtual CoinsList listCoins()=0
virtual CAmount getBalance()=0
Get balance.
virtual WalletBalances getBalances()=0
Get balances.
virtual std::vector< std::string > getAddressReceiveRequests()=0
Get receive requests.
std::string ToString() const
PreselectedInput & Select(const COutPoint &outpoint)
Lock-in the given output for spending.
CTxDestination destChange
Custom change destination, if not set an address is generated.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Descriptor with some wallet metadata.
RAII object to check and reserve a wallet rescan.
static UniValue Parse(std::string_view raw, ParamFormat format=ParamFormat::JSON)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
const std::string CURRENCY_UNIT
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeSecret(const CKey &key)
std::string EncodeDestination(const CTxDestination &dest)
std::unique_ptr< WalletLoader > MakeWalletLoader(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet loader.
std::unique_ptr< Wallet > MakeWallet(wallet::WalletContext &context, const std::shared_ptr< wallet::CWallet > &wallet)
Return implementation of Wallet interface.
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
bool DecodeRawPSBT(PartiallySignedTransaction &psbt, std::span< const std::byte > tx_data, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
void ConfirmMessage(QString *text, std::chrono::milliseconds msec)
Press "Ok" button in message box dialog.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
auto MakeByteSpan(const V &v) noexcept
A version of CTransaction with the PSBT format.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate *chainstate=nullptr)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
interfaces::WalletLoader * wallet_loader
std::unique_ptr< interfaces::Chain > chain
WalletContext struct containing references to state shared between CWallet instances,...
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
ChangeType
General change type (added, updated, removed).
std::optional< std::vector< unsigned char > > DecodeBase64(std::string_view str)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.