MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ipcParseCommandLine

Method ipcParseCommandLine

src/qt/paymentserver.cpp:193–248  ·  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 "Q_EMIT message()", but "QMessageBox::"!

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

parseBitcoinURIFunction · 0.85
CreateChainParamsFunction · 0.85
IsValidDestinationStringFunction · 0.85
selectParamsMethod · 0.80

Tested by

no test coverage detected