Skip to content

Commit 861ff74

Browse files
committed
Restrict results for blockchain.estimatefee
Let's do what ElectrumX is doing and not return the full dictionary from `getmempoolinfo` and instead restrict it to a subset of useful keys to preserve privacy.
1 parent a3236b7 commit 861ff74

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Servers.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,8 +2413,19 @@ void Server::rpc_mempool_get_fee_histogram(Client *c, const RPC::BatchId batchId
24132413
void Server::rpc_mempool_get_info(Client *c, const RPC::BatchId batchId, const RPC::Message &m)
24142414
{
24152415
constexpr int kMempoolInfoStaleThreshMS = 5'000; // if older than 5 secs, refresh
2416-
generic_async_to_bitcoind(c, batchId, m.id, "getmempoolinfo", QVariantList{}, BitcoinDSuccessFunc{}, BitcoinDErrorFunc{},
2417-
kMempoolInfoStaleThreshMS);
2416+
generic_async_to_bitcoind(c, batchId, m.id, "getmempoolinfo", QVariantList{},
2417+
[](const RPC::Message &response){
2418+
// to preserve privacy, only grab the following keys, omitting size, bytes, etc
2419+
constexpr const char * desiredKeys[] = { "mempoolminfee", "minrelaytxfee", "incrementalrelayfee",
2420+
"unbroadcastcount", "fullrbf" };
2421+
QVariantMap m = response.result().toMap(), ret;
2422+
for (const auto & key : desiredKeys)
2423+
if (m.contains(key)) ret[key] = m.value(key);
2424+
return ret;
2425+
},
2426+
BitcoinDErrorFunc{},
2427+
kMempoolInfoStaleThreshMS
2428+
);
24182429
}
24192430

24202431
void Server::rpc_daemon_passthrough(Client *c, const RPC::BatchId batchId, const RPC::Message &m)

0 commit comments

Comments
 (0)