Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12428774
D583.id2085.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D583.id2085.diff
View Options
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -214,6 +214,37 @@
} // ns anon
+static bool ipcParseURI(const QString &arg) {
+
+ std::vector<std::string> networks = {CBaseChainParams::MAIN,
+ CBaseChainParams::TESTNET,
+ CBaseChainParams::REGTEST};
+
+ for (std::string net : networks) {
+ const CChainParams ¶ms(Params(net));
+ SchemeCfgDummy cfg(params);
+ const QString scheme = GUIUtil::bitcoinURIScheme(cfg);
+
+ if (!arg.startsWith(scheme + ":", Qt::CaseInsensitive)) {
+ continue;
+ }
+
+ SendCoinsRecipient r;
+ if (!GUIUtil::parseBitcoinURI(scheme, arg, &r)) {
+ return false;
+ }
+
+ if (!IsValidDestinationString(r.address.toStdString(), params)) {
+ return false;
+ }
+
+ savedPaymentRequests.append(arg);
+ SelectParams(net);
+ return true;
+ }
+ return false;
+}
+
//
// Sending to the server is done synchronously, at startup.
// If the server isn't already running, startup continues, and the items in
@@ -227,31 +258,11 @@
QString arg(argv[i]);
if (arg.startsWith("-")) continue;
- SchemeCfgDummy cfg(Params(CBaseChainParams::MAIN));
- QString scheme = GUIUtil::bitcoinURIScheme(cfg);
- // If the bitcoincash: URI contains a payment request, we are not able
- // to detect the network as that would require fetching and parsing the
- // payment request. That means clicking such an URI which contains a
- // testnet payment request will start a mainnet instance and throw a
- // "wrong network" error.
- if (arg.startsWith(scheme + ":",
- Qt::CaseInsensitive)) // bitcoincash: URI
- {
- savedPaymentRequests.append(arg);
+ if (ipcParseURI(arg)) {
+ continue;
+ }
- SendCoinsRecipient r;
- if (GUIUtil::parseBitcoinURI(scheme, arg, &r) &&
- !r.address.isEmpty()) {
- if (IsValidDestinationString(r.address.toStdString(),
- Params(CBaseChainParams::MAIN))) {
- SelectParams(CBaseChainParams::MAIN);
- } else if (IsValidDestinationString(
- r.address.toStdString(),
- Params(CBaseChainParams::TESTNET))) {
- SelectParams(CBaseChainParams::TESTNET);
- }
- }
- } else if (QFile::exists(arg)) {
+ if (QFile::exists(arg)) {
// Filename
savedPaymentRequests.append(arg);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 28, 19:39 (8 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4844977
Default Alt Text
D583.id2085.diff (2 KB)
Attached To
D583: Support parsing cashaddr from command line
Event Timeline
Log In to Comment