Skip to content

Commit

Permalink
issue cculianu#181 preserve pre-25.0 functionality for sendrawtransac…
Browse files Browse the repository at this point in the history
…tion and fix one small typo (Vulberable)
  • Loading branch information
BamaHodl authored and BamaHodl committed Jun 30, 2023
1 parent d628948 commit d9ef13d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Servers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,16 @@ void Server::rpc_blockchain_transaction_broadcast(Client *c, const RPC::BatchId
// -- filter may end up applying murmur3 hash to the entire key we give it from 20-50 times!
const QByteArray txkey = (!rawtxhex.isEmpty() ? BTC::HashOnce(Util::ParseHexFast(rawtxhex)).left(16) : QByteArrayLiteral("xx"));
// no need to validate hex here -- bitcoind does validation for us!
generic_async_to_bitcoind(c, batchId, m.id, "sendrawtransaction", QVariantList{ rawtxhex },
QVariantList params { rawtxhex } ;
if ((bitcoindmgr->isCoreLike())
&& bitcoindmgr->getBitcoinDVersion() >= Version{0,25,0}) {
// bitcoin core 25.0+ requires specifying maxburnamount in sendrawtransaction call
// which also requires first sending maxfeerate, set to 0.1btc by default in core
params.append(0.1);
// set maxburnrate to max btc supply to preserve pre-25.0 functionality
params.append(21000000);
}
generic_async_to_bitcoind(c, batchId, m.id, "sendrawtransaction", params,
// print to log, echo bitcoind's reply to client
[size=rawtxhex.length()/2, c, this, txkey](const RPC::Message & reply){
QVariant ret = reply.result();
Expand All @@ -1842,8 +1851,8 @@ void Server::rpc_blockchain_transaction_broadcast(Client *c, const RPC::BatchId
logFilter->broadcast(true, logLine, txkey);
// Next, check if client is old and has the phishing exploit:
// version 3.3.4 was the first one that was good for both Electron Cash and Electrum
constexpr Version FirstNonVulberableVersion(3,3,4);
if (const auto uaVersion = c->info.uaVersion(); uaVersion.isValid() && uaVersion < FirstNonVulberableVersion) {
constexpr Version FirstNonVulnerableVersion(3,3,4);
if (const auto uaVersion = c->info.uaVersion(); uaVersion.isValid() && uaVersion < FirstNonVulnerableVersion) {
// The below is to warn old clients that they are vulnerable to a phishing attack.
// This logic is also used by the ElectronX implementations here:
// https://github.com/Electron-Cash/electrumx/blob/fbd00416d804c286eb7de856e9399efb07a2ceaf/electrumx/server/session.py#L1526
Expand Down

0 comments on commit d9ef13d

Please sign in to comment.