Skip to content

Commit 93feabc

Browse files
committed
Merge bitcoin-core/gui#563: qt: Remove network detection based on address in BIP21
b7dbc83 qt: Remove network detection based on address in BIP21 (laanwj) Pull request description: This is removes some ugly and brittle code that switches the global network to testnet based on a provided address. I think in practice it's very unlikely for testnet BIP21 payment URIs to be used, and if so it's for testing so it's easy enough to manually copy it. Or to specify `-testnet` explicitly. There is already no such case for `-regtest` or `-signet`. After this change it will only accept addresses for the explicitly selected network. Others will result in a "wrong network" popup. There is also a possibility for refactor after this as the initialization order of `PaymentServer::ipcParseCommandLine` isn't important anymore (well, it still has to be before `PaymentServer::ipcSendCommandLine`, maybe even merged with it), but I have not done so here. ACKs for top commit: jonatack: ACK b7dbc83 achow101: ACK b7dbc83 Tree-SHA512: ebc77c0e5c98f53fe254bcd0f94c9d1c06937b794346e95b14158860d5c607515e71d73b782d2726674dce86d6d4001085d473c6d1bc11c5e6c25ff3fb3cfa22
2 parents 597ee30 + b7dbc83 commit 93feabc

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ int GuiMain(int argc, char* argv[])
587587
return EXIT_FAILURE;
588588
}
589589
#ifdef ENABLE_WALLET
590-
// Parse URIs on command line -- this can affect Params()
590+
// Parse URIs on command line
591591
PaymentServer::ipcParseCommandLine(argc, argv);
592592
#endif
593593

src/qt/paymentserver.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,11 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[])
7878
for (int i = 1; i < argc; i++)
7979
{
8080
QString arg(argv[i]);
81-
if (arg.startsWith("-"))
82-
continue;
81+
if (arg.startsWith("-")) continue;
8382

84-
// If the bitcoin: URI contains a payment request, we are not able to detect the
85-
// network as that would require fetching and parsing the payment request.
86-
// That means clicking such an URI which contains a testnet payment request
87-
// will start a mainnet instance and throw a "wrong network" error.
8883
if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
8984
{
90-
if (savedPaymentRequests.contains(arg)) continue;
9185
savedPaymentRequests.insert(arg);
92-
93-
SendCoinsRecipient r;
94-
if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty())
95-
{
96-
auto tempChainParams = CreateChainParams(gArgs, CBaseChainParams::MAIN);
97-
98-
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
99-
SelectParams(CBaseChainParams::MAIN);
100-
} else {
101-
tempChainParams = CreateChainParams(gArgs, CBaseChainParams::TESTNET);
102-
if (IsValidDestinationString(r.address.toStdString(), *tempChainParams)) {
103-
SelectParams(CBaseChainParams::TESTNET);
104-
}
105-
}
106-
}
10786
}
10887
}
10988
}

0 commit comments

Comments
 (0)