Skip to content

Commit 8f39aaa

Browse files
fjahrstickies-v
andcommitted
refactor: Remove hooking code for urlDecode
The point of this was to be able to build bitcoin-tx and bitcoin-wallet without libevent, see #18504. Now that we use our own implementation of urlDecode this is not needed anymore. Co-authored-by: stickies-v <stickies-v@protonmail.com>
1 parent 650d43e commit 8f39aaa

File tree

7 files changed

+7
-15
lines changed

7 files changed

+7
-15
lines changed

src/bitcoin-cli.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <clientversion.h>
1212
#include <common/args.h>
1313
#include <common/system.h>
14-
#include <common/url.h>
1514
#include <compat/compat.h>
1615
#include <compat/stdin.h>
1716
#include <policy/feerate.h>
@@ -51,7 +50,6 @@
5150
using CliClock = std::chrono::system_clock;
5251

5352
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
54-
UrlDecodeFn* const URL_DECODE = urlDecode;
5553

5654
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
5755
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;

src/bitcoin-wallet.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <clientversion.h>
1212
#include <common/args.h>
1313
#include <common/system.h>
14-
#include <common/url.h>
1514
#include <compat/compat.h>
1615
#include <interfaces/init.h>
1716
#include <key.h>
@@ -28,7 +27,6 @@
2827
#include <tuple>
2928

3029
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
31-
UrlDecodeFn* const URL_DECODE = nullptr;
3230

3331
static void SetupWalletToolArgs(ArgsManager& argsman)
3432
{

src/bitcoind.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <common/args.h>
1313
#include <common/init.h>
1414
#include <common/system.h>
15-
#include <common/url.h>
1615
#include <compat/compat.h>
1716
#include <init.h>
1817
#include <interfaces/chain.h>
@@ -35,7 +34,6 @@
3534
using node::NodeContext;
3635

3736
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
38-
UrlDecodeFn* const URL_DECODE = urlDecode;
3937

4038
#if HAVE_DECL_FORK
4139

src/common/url.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
#include <string>
99
#include <string_view>
1010

11-
using UrlDecodeFn = std::string(std::string_view url_encoded);
12-
UrlDecodeFn urlDecode;
13-
extern UrlDecodeFn* const URL_DECODE;
11+
/* Decode a URL.
12+
*
13+
* Notably this implementation does not decode a '+' to a ' '.
14+
*/
15+
std::string urlDecode(std::string_view url_encoded);
1416

1517
#endif // BITCOIN_COMMON_URL_H

src/qt/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <qt/bitcoin.h>
66

7-
#include <common/url.h>
87
#include <compat/compat.h>
98
#include <util/translation.h>
109

@@ -17,7 +16,6 @@
1716
extern const std::function<std::string(const char*)> G_TRANSLATION_FUN = [](const char* psz) {
1817
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
1918
};
20-
UrlDecodeFn* const URL_DECODE = urlDecode;
2119

2220
const std::function<std::string()> G_TEST_GET_FULL_NAME{};
2321

src/test/util/setup_common.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <banman.h>
1515
#include <chainparams.h>
1616
#include <common/system.h>
17-
#include <common/url.h>
1817
#include <consensus/consensus.h>
1918
#include <consensus/params.h>
2019
#include <consensus/validation.h>
@@ -81,7 +80,6 @@ using node::RegenerateCommitments;
8180
using node::VerifyLoadedChainstate;
8281

8382
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
84-
UrlDecodeFn* const URL_DECODE = nullptr;
8583

8684
/** Random context to get unique temp data dirs. Separate from g_insecure_rand_ctx, which can be seeded from a const env var */
8785
static FastRandomContext g_insecure_rand_ctx_temp_path;

src/wallet/rpc/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ bool ParseIncludeWatchonly(const UniValue& include_watchonly, const CWallet& wal
6262

6363
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request, std::string& wallet_name)
6464
{
65-
if (URL_DECODE && request.URI.starts_with(WALLET_ENDPOINT_BASE)) {
65+
if (request.URI.starts_with(WALLET_ENDPOINT_BASE)) {
6666
// wallet endpoint was used
67-
wallet_name = URL_DECODE(std::string_view{request.URI}.substr(WALLET_ENDPOINT_BASE.size()));
67+
wallet_name = urlDecode(std::string_view{request.URI}.substr(WALLET_ENDPOINT_BASE.size()));
6868
return true;
6969
}
7070
return false;

0 commit comments

Comments
 (0)