 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
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(
"-"))
119 bool fResult =
false;
122 QLocalSocket* socket =
new QLocalSocket();
123 socket->connectToServer(
ipcServerName(), QIODevice::WriteOnly);
132 QDataStream out(&block, QIODevice::WriteOnly);
133 out.setVersion(QDataStream::Qt_4_0);
135 out.device()->seek(0);
137 socket->write(block);
140 socket->disconnectFromServer();
154 optionsModel(nullptr)
160 parent->installEventFilter(
this);
165 QLocalServer::removeServer(
name);
167 if (startLocalServer)
173 QMessageBox::critical(
nullptr, tr(
"Payment request error"),
174 tr(
"Cannot start bitcoin: click-to-pay handler"));
191 if (event->type() == QEvent::FileOpen) {
192 QFileOpenEvent *fileEvent =
static_cast<QFileOpenEvent*
>(event);
193 if (!fileEvent->file().isEmpty())
195 else if (!fileEvent->url().isEmpty())
201 return QObject::eventFilter(
object, event);
222 if (s.startsWith(
"bitcoin://", Qt::CaseInsensitive))
224 Q_EMIT
message(tr(
"URI handling"), tr(
"'bitcoin://' is not a valid URI. Use 'bitcoin:' instead."),
229 QUrlQuery uri((QUrl(s)));
235 std::string error_msg;
239 if (uri.hasQueryItem(
"r")) {
240 Q_EMIT
message(tr(
"URI 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."),
246 Q_EMIT
message(tr(
"URI handling"), QString::fromStdString(error_msg),
253 Q_EMIT
message(tr(
"URI handling"),
254 tr(
"URI cannot be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
263 Q_EMIT
message(tr(
"Payment request file handling"),
264 tr(
"Cannot process payment request because BIP70 is not supported.\n"
265 "Due to widespread security flaws in BIP70 it's strongly recommended that any merchant instructions to switch wallets be ignored.\n"
266 "If you are receiving this error you should request the merchant provide a BIP21 compatible URI."),
273 QLocalSocket *clientConnection =
uriServer->nextPendingConnection();
275 while (clientConnection->bytesAvailable() < (
int)
sizeof(quint32))
276 clientConnection->waitForReadyRead();
278 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
280 QDataStream in(clientConnection);
281 in.setVersion(QDataStream::Qt_4_0);
282 if (clientConnection->bytesAvailable() < (
int)
sizeof(quint16)) {
QString PathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
static bool exists(const path &p)
OptionsModel * optionsModel
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
void message(const QString &title, const QString &message, unsigned int style)
const QString BITCOIN_IPC_PREFIX("bitcoin:")
void setOptionsModel(OptionsModel *optionsModel)
static const std::string TESTNET
void handleURIConnection()
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
static void ipcParseCommandLine(int argc, char *argv[])
static bool ipcSendCommandLine()
Interface from Qt to configuration data structure for Bitcoin client.
static QString ipcServerName()
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
void receivedPaymentRequest(SendCoinsRecipient)
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
static QSet< QString > savedPaymentRequests
static const std::string MAIN
Chain name strings.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
void handleURIOrFile(const QString &s)
const int BITCOIN_IPC_CONNECT_TIMEOUT
bool eventFilter(QObject *object, QEvent *event) override
PaymentServer(QObject *parent, bool startLocalServer=true)
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.