MCPcopy Create free account
hub / github.com/LUX-Core/lux / ipcParseCommandLine

Method ipcParseCommandLine

src/qt/paymentserver.cpp:188–239  ·  view source on GitHub ↗

Sending to the server is done synchronously, at startup. If the server isn't already running, startup continues, and the items in savedPaymentRequest will be handled when uiReady() is called. Warning: ipcSendCommandLine() is called early in init, so don't use "emit message()", but "QMessageBox::"!

Source from the content-addressed store, hash-verified

186// so don't use "emit message()", but "QMessageBox::"!
187//
188void PaymentServer::ipcParseCommandLine(int argc, char* argv[])
189{
190 for (int i = 1; i < argc; i++) {
191 QString arg(argv[i]);
192 if (arg.startsWith("-"))
193 continue;
194
195 // If the lux: URI contains a payment request, we are not able to detect the
196 // network as that would require fetching and parsing the payment request.
197 // That means clicking such an URI which contains a testnet payment request
198 // will start a mainnet instance and throw a "wrong network" error.
199 if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // lux: URI
200 {
201 savedPaymentRequests.append(arg);
202
203 SendCoinsRecipient r;
204 if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty()) {
205 auto tempChainParams = CreateChainParams(CBaseChainParams::MAIN);
206
207 if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
208 SelectParams(CBaseChainParams::MAIN);
209 } else {
210 tempChainParams = CreateChainParams(CBaseChainParams::TESTNET);
211 if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
212 SelectParams(CBaseChainParams::TESTNET);
213 } else {
214 tempChainParams = CreateChainParams(CBaseChainParams::SEGWITTEST);
215 if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
216 SelectParams(CBaseChainParams::SEGWITTEST);
217 }
218 }
219 }
220 }
221 } else if (QFile::exists(arg)) // Filename
222 {
223 savedPaymentRequests.append(arg);
224
225 PaymentRequestPlus request;
226 if (readPaymentRequestFromFile(arg, request)) {
227 if (request.getDetails().network() == "main") {
228 SelectParams(CBaseChainParams::MAIN);
229 } else if (request.getDetails().network() == "test") {
230 SelectParams(CBaseChainParams::TESTNET);
231 }
232 }
233 } else {
234 // Printing to debug.log is about the best we can do here, the
235 // GUI hasn't started yet so we can't pop up a message box.
236 qWarning() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << arg;
237 }
238 }
239}
240
241//
242// Sending to the server is done synchronously, at startup.

Callers

nothing calls this directly

Calls 6

parseBitcoinURIFunction · 0.85
CreateChainParamsFunction · 0.85
IsValidDestinationStringFunction · 0.85
SelectParamsFunction · 0.85
appendMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected