5 #if defined(HAVE_CONFIG_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();
133 optionsModel(nullptr)
139 parent->installEventFilter(
this);
144 QLocalServer::removeServer(
name);
146 if (startLocalServer)
152 QMessageBox::critical(
nullptr, tr(
"Payment request error"),
153 tr(
"Cannot start bitcoin: click-to-pay handler"));
168 if (event->type() == QEvent::FileOpen) {
169 QFileOpenEvent *fileEvent =
static_cast<QFileOpenEvent*
>(event);
170 if (!fileEvent->file().isEmpty())
172 else if (!fileEvent->url().isEmpty())
178 return QObject::eventFilter(
object, event);
199 if (s.startsWith(
"bitcoin://", Qt::CaseInsensitive))
201 Q_EMIT
message(tr(
"URI handling"), tr(
"'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
206 QUrlQuery uri((QUrl(s)));
212 std::string error_msg;
216 if (uri.hasQueryItem(
"r")) {
217 Q_EMIT
message(tr(
"URI handling"),
218 tr(
"Cannot process payment request because BIP70 is not supported.\n" 219 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n" 220 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
223 Q_EMIT
message(tr(
"URI handling"), QString::fromStdString(error_msg),
230 Q_EMIT
message(tr(
"URI handling"),
231 tr(
"URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
240 Q_EMIT
message(tr(
"Payment request file handling"),
241 tr(
"Cannot process payment request because BIP70 is not supported.\n" 242 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n" 243 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
250 QLocalSocket *clientConnection =
uriServer->nextPendingConnection();
252 while (clientConnection->bytesAvailable() < (int)
sizeof(quint32))
253 clientConnection->waitForReadyRead();
255 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
257 QDataStream in(clientConnection);
258 in.setVersion(QDataStream::Qt_4_0);
259 if (clientConnection->bytesAvailable() < (int)
sizeof(quint16)) {
void message(const QString &title, const QString &message, unsigned int style)
void setOptionsModel(OptionsModel *optionsModel)
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
void receivedPaymentRequest(SendCoinsRecipient)
bool eventFilter(QObject *object, QEvent *event) override
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
static void ipcParseCommandLine(int argc, char *argv[])
void handleURIOrFile(const QString &s)
static bool ipcSendCommandLine()
static QSet< QString > savedPaymentRequests
const int BITCOIN_IPC_CONNECT_TIMEOUT
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
PaymentServer(QObject *parent, bool startLocalServer=true)
Interface from Qt to configuration data structure for Bitcoin client.
const QString BITCOIN_IPC_PREFIX("bitcoin:")
static QString ipcServerName()
void handleURIConnection()
OptionsModel * optionsModel
static bool exists(const path &p)
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.
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.