11 #include <chainparams.h> 22 #include <QApplication> 24 #include <QDataStream> 27 #include <QFileOpenEvent> 30 #include <QLocalServer> 31 #include <QLocalSocket> 32 #include <QStringList> 45 QString
name(
"BitcoinQt");
51 name.append(QString::number(qHash(ddir)));
74 for (
int i = 1; i < argc; i++)
77 if (arg.startsWith(
"-"))
continue;
97 QLocalSocket* socket =
new QLocalSocket();
98 socket->connectToServer(
ipcServerName(), QIODevice::WriteOnly);
107 QDataStream
out(&block, QIODevice::WriteOnly);
108 out.setVersion(QDataStream::Qt_4_0);
110 out.device()->seek(0);
112 socket->write(block);
115 socket->disconnectFromServer();
132 parent->installEventFilter(
this);
137 QLocalServer::removeServer(
name);
139 if (startLocalServer)
145 QMessageBox::critical(
nullptr, tr(
"Payment request error"),
146 tr(
"Cannot start bitcoin: click-to-pay handler"));
161 if (event->type() == QEvent::FileOpen) {
162 QFileOpenEvent *fileEvent =
static_cast<QFileOpenEvent*
>(event);
163 if (!fileEvent->file().isEmpty())
165 else if (!fileEvent->url().isEmpty())
171 return QObject::eventFilter(
object, event);
192 if (s.startsWith(
"bitcoin://", Qt::CaseInsensitive))
194 Q_EMIT
message(tr(
"URI handling"), tr(
"'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
199 QUrlQuery uri((QUrl(s)));
205 std::string error_msg;
209 if (uri.hasQueryItem(
"r")) {
210 Q_EMIT
message(tr(
"URI handling"),
211 tr(
"Cannot process payment request because BIP70 is not supported.\n" 212 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n" 213 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
216 Q_EMIT
message(tr(
"URI handling"), QString::fromStdString(error_msg),
223 Q_EMIT
message(tr(
"URI handling"),
224 tr(
"URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
233 Q_EMIT
message(tr(
"Payment request file handling"),
234 tr(
"Cannot process payment request because BIP70 is not supported.\n" 235 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n" 236 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
243 QLocalSocket *clientConnection =
uriServer->nextPendingConnection();
245 while (clientConnection->bytesAvailable() < (int)
sizeof(quint32))
246 clientConnection->waitForReadyRead();
248 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
250 QDataStream in(clientConnection);
251 in.setVersion(QDataStream::Qt_4_0);
252 if (clientConnection->bytesAvailable() < (int)
sizeof(quint16)) {
void message(const QString &title, const QString &message, unsigned int style)
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
void setOptionsModel(OptionsModel *optionsModel)
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
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
const int BITCOIN_IPC_CONNECT_TIMEOUT
PaymentServer(QObject *parent, bool startLocalServer=true)
Interface from Qt to configuration data structure for Bitcoin client.
const QString BITCOIN_IPC_PREFIX("bitcoin:")
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
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.