5 #if defined(HAVE_CONFIG_H)
26 #include <QApplication>
28 #include <QDataStream>
32 #include <QFileOpenEvent>
35 #include <QLocalServer>
36 #include <QLocalSocket>
37 #include <QStringList>
50 QString
name(
"BitcoinQt");
56 name.append(QString::number(qHash(ddir)));
79 for (
int i = 1; i < argc; i++)
82 if (arg.startsWith(
"-"))
120 bool fResult =
false;
123 QLocalSocket* socket =
new QLocalSocket();
124 socket->connectToServer(
ipcServerName(), QIODevice::WriteOnly);
133 QDataStream out(&block, QIODevice::WriteOnly);
134 out.setVersion(QDataStream::Qt_4_0);
136 out.device()->seek(0);
138 socket->write(block);
141 socket->disconnectFromServer();
155 optionsModel(nullptr)
161 parent->installEventFilter(
this);
166 QLocalServer::removeServer(name);
168 if (startLocalServer)
174 QMessageBox::critical(
nullptr, tr(
"Payment request error"),
175 tr(
"Cannot start bitcoin: click-to-pay handler"));
192 if (event->type() == QEvent::FileOpen) {
193 QFileOpenEvent *fileEvent =
static_cast<QFileOpenEvent*
>(event);
194 if (!fileEvent->file().isEmpty())
196 else if (!fileEvent->url().isEmpty())
202 return QObject::eventFilter(
object, event);
212 savedPaymentRequests.clear();
223 if (s.startsWith(
"bitcoin://", Qt::CaseInsensitive))
225 Q_EMIT
message(tr(
"URI handling"), tr(
"'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
230 QUrlQuery uri((QUrl(s)));
237 if (uri.hasQueryItem(
"r")) {
238 Q_EMIT
message(tr(
"URI handling"),
239 tr(
"Cannot process payment request because BIP70 is not supported.")+
240 tr(
"Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.")+
241 tr(
"If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
244 Q_EMIT
message(tr(
"URI handling"), tr(
"Invalid payment address %1").arg(recipient.
address),
251 Q_EMIT
message(tr(
"URI handling"),
252 tr(
"URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
259 if (QFile::exists(s))
261 Q_EMIT
message(tr(
"Payment request file handling"),
262 tr(
"Cannot process payment request because BIP70 is not supported.")+
263 tr(
"Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.")+
264 tr(
"If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
271 QLocalSocket *clientConnection =
uriServer->nextPendingConnection();
273 while (clientConnection->bytesAvailable() < (int)
sizeof(quint32))
274 clientConnection->waitForReadyRead();
276 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
278 QDataStream in(clientConnection);
279 in.setVersion(QDataStream::Qt_4_0);
280 if (clientConnection->bytesAvailable() < (int)
sizeof(quint16)) {
void message(const QString &title, const QString &message, unsigned int style)
void setOptionsModel(OptionsModel *optionsModel)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
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 const std::string MAIN
Chain name strings.
static bool ipcSendCommandLine()
static QSet< QString > savedPaymentRequests
const int BITCOIN_IPC_CONNECT_TIMEOUT
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
const fs::path & GetDataDir(bool fNetSpecific)
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()
static const std::string TESTNET
OptionsModel * optionsModel
QString boostPathToQString(const fs::path &path)
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr of the chosen chain.