5 #if defined(HAVE_CONFIG_H)
15 #include <chainparams.h>
26 #include <QApplication>
28 #include <QDataStream>
31 #include <QFileOpenEvent>
34 #include <QLocalServer>
35 #include <QLocalSocket>
36 #include <QStringList>
49 QString
name(
"BitcoinQt");
55 name.append(QString::number(qHash(ddir)));
78 for (
int i = 1; i < argc; i++)
81 if (arg.startsWith(
"-"))
continue;
101 QLocalSocket* socket =
new QLocalSocket();
102 socket->connectToServer(
ipcServerName(), QIODevice::WriteOnly);
111 QDataStream
out(&block, QIODevice::WriteOnly);
112 out.setVersion(QDataStream::Qt_4_0);
114 out.device()->seek(0);
116 socket->write(block);
119 socket->disconnectFromServer();
136 parent->installEventFilter(
this);
141 QLocalServer::removeServer(
name);
143 if (startLocalServer)
149 QMessageBox::critical(
nullptr, tr(
"Payment request error"),
150 tr(
"Cannot start bitcoin: click-to-pay handler"));
165 if (event->type() == QEvent::FileOpen) {
166 QFileOpenEvent *fileEvent =
static_cast<QFileOpenEvent*
>(event);
167 if (!fileEvent->file().isEmpty())
169 else if (!fileEvent->url().isEmpty())
175 return QObject::eventFilter(
object, event);
196 if (s.startsWith(
"bitcoin://", Qt::CaseInsensitive))
198 Q_EMIT
message(tr(
"URI handling"), tr(
"'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
203 QUrlQuery uri((QUrl(s)));
209 std::string error_msg;
213 if (uri.hasQueryItem(
"r")) {
214 Q_EMIT
message(tr(
"URI handling"),
215 tr(
"Cannot process payment request because BIP70 is not supported.\n"
216 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n"
217 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
220 Q_EMIT
message(tr(
"URI handling"), QString::fromStdString(error_msg),
227 Q_EMIT
message(tr(
"URI handling"),
228 tr(
"URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
237 Q_EMIT
message(tr(
"Payment request file handling"),
238 tr(
"Cannot process payment request because BIP70 is not supported.\n"
239 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n"
240 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
247 QLocalSocket *clientConnection =
uriServer->nextPendingConnection();
249 while (clientConnection->bytesAvailable() < (
int)
sizeof(quint32))
250 clientConnection->waitForReadyRead();
252 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
254 QDataStream in(clientConnection);
255 in.setVersion(QDataStream::Qt_4_0);
256 if (clientConnection->bytesAvailable() < (
int)
sizeof(quint16)) {
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
Interface from Qt to configuration data structure for Bitcoin client.
static bool ipcSendCommandLine()
void setOptionsModel(OptionsModel *optionsModel)
PaymentServer(QObject *parent, bool startLocalServer=true)
void message(const QString &title, const QString &message, unsigned int style)
void handleURIConnection()
static void ipcParseCommandLine(int argc, char *argv[])
void receivedPaymentRequest(SendCoinsRecipient)
bool eventFilter(QObject *object, QEvent *event) override
void handleURIOrFile(const QString &s)
OptionsModel * optionsModel
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
QString PathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
static bool exists(const path &p)
static QString ipcServerName()
const int BITCOIN_IPC_CONNECT_TIMEOUT
const QString BITCOIN_IPC_PREFIX("bitcoin:")
static QSet< QString > savedPaymentRequests
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.