23#include <QApplication>
34void EditAddressAndSubmit(
36 const QString& label,
const QString& address, QString expected_msg)
40 dialog->findChild<QLineEdit*>(
"labelEdit")->setText(label);
45 QCOMPARE(warning_text, expected_msg);
71 wallet->SetupDescriptorScriptPubKeyMans();
74 auto build_address = [&
wallet]() {
86 QString preexisting_r_address;
87 QString r_label(
"already here (r)");
90 QString preexisting_s_address;
91 QString s_label(
"already here (s)");
96 std::tie(r_key_dest, preexisting_r_address) = build_address();
97 std::tie(s_key_dest, preexisting_s_address) = build_address();
98 std::tie(std::ignore, new_address) = build_address();
102 wallet->SetAddressBook(r_key_dest, r_label.toStdString(),
"receive");
103 wallet->SetAddressBook(s_key_dest, s_label.toStdString(),
"send");
106 auto check_addbook_size = [&
wallet](
int expected_size) {
108 QCOMPARE(
static_cast<int>(
wallet->m_address_book.size()), expected_size);
112 check_addbook_size(2);
123 editAddressDialog.setModel(walletModel.getAddressTableModel());
125 EditAddressAndSubmit(
126 &editAddressDialog, QString(
"uhoh"), preexisting_r_address,
128 "Address \"%1\" already exists as a receiving address with label "
129 "\"%2\" and so cannot be added as a sending address."
130 ).arg(preexisting_r_address).arg(r_label));
132 check_addbook_size(2);
134 EditAddressAndSubmit(
135 &editAddressDialog, QString(
"uhoh, different"), preexisting_s_address,
137 "The entered address \"%1\" is already in the address book with "
139 ).arg(preexisting_s_address).arg(s_label));
141 check_addbook_size(2);
145 EditAddressAndSubmit(
146 &editAddressDialog, QString(
"new"), new_address, QString(
""));
148 check_addbook_size(3);
156 if (QApplication::platformName() ==
"minimal") {
161 QWARN(
"Skipping AddressBookTests on mac build with 'minimal' platform set due to Qt bugs. To run AppTests, invoke "
162 "with 'QT_QPA_PLATFORM=cocoa test_bitcoin-qt' on mac, or else use a linux or windows build.");
166 TestAddAddressesToSendBook(
m_node);
#define Assert(val)
Identity function.
interfaces::Node & m_node
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
Model for Bitcoin network client.
Dialog for editing an address and associated information.
Interface from Qt to configuration data structure for Bitcoin client.
Line edit that can be marked as "invalid" to show input validation feedback.
Interface to Bitcoin wallet from Qt view code.
Top-level interface for a bitcoin node (bitcoind process).
std::string EncodeDestination(const CTxDestination &dest)
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
std::unique_ptr< WalletClient > MakeWalletClient(Chain &chain, ArgsManager &args)
Return implementation of ChainClient interface for a wallet client.
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
void ConfirmMessage(QString *text, int msec)
Press "Ok" button in message box dialog.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::unique_ptr< interfaces::Chain > chain
interfaces::WalletClient * wallet_client
Reference to chain client that should used to load or create wallets opened by the gui.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
WalletContext struct containing references to state shared between CWallet instances,...
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
std::unique_ptr< WalletDatabase > CreateMockWalletDatabase()
Return object for accessing temporary in-memory database.
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.