Skip to content

Commit 143ace6

Browse files
committed
Merge bitcoin/bitcoin#28890: rpc: Remove deprecated -rpcserialversion
fa46cc2 Remove deprecated -rpcserialversion (MarcoFalke) Pull request description: The flag is problematic for many reasons: * It is deprecated * It is a global flag, requiring a restart to change, as opposed to a flag that can be set on each RPC invocation * It may be hidden in config files by accident, hard to debug, causing LND crashes and bugs, see bitcoin/bitcoin#28730 (comment) * It makes performance improvements harder to implement: bitcoin/bitcoin#17529 (comment) Fix all issues by removing it. If there is a use-case, likely a per-RPC flag can be added, if needed. ACKs for top commit: ajtowns: crACK fa46cc2 TheCharlatan: lgtm ACK fa46cc2 Tree-SHA512: 96ba1c60356ce93954fe5c2a59045771c6d1516ad0d9dc436ef1800a1f1b0153f0d5fb78ca99d53ad54ba25fbce36962bdf1d4325aceedfc8154a61347a6a915
2 parents d445545 + fa46cc2 commit 143ace6

File tree

14 files changed

+19
-80
lines changed

14 files changed

+19
-80
lines changed

src/core_io.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ bool ParseHashStr(const std::string& strHex, uint256& result);
5151
// core_write.cpp
5252
UniValue ValueFromAmount(const CAmount amount);
5353
std::string FormatScript(const CScript& script);
54-
std::string EncodeHexTx(const CTransaction& tx, const bool without_witness = false);
54+
std::string EncodeHexTx(const CTransaction& tx);
5555
std::string SighashToStr(unsigned char sighash_type);
5656
void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex = true, bool include_address = false, const SigningProvider* provider = nullptr);
57-
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex = true, bool without_witness = false, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS);
57+
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex = true, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS);
5858

5959
#endif // BITCOIN_CORE_IO_H

src/core_write.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,10 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
140140
return str;
141141
}
142142

143-
std::string EncodeHexTx(const CTransaction& tx, const bool without_witness)
143+
std::string EncodeHexTx(const CTransaction& tx)
144144
{
145145
DataStream ssTx;
146-
if (without_witness) {
147-
ssTx << TX_NO_WITNESS(tx);
148-
} else {
149-
ssTx << TX_WITH_WITNESS(tx);
150-
}
146+
ssTx << TX_WITH_WITNESS(tx);
151147
return HexStr(ssTx);
152148
}
153149

@@ -172,7 +168,7 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex, bool i
172168
out.pushKV("type", GetTxnOutputType(type));
173169
}
174170

175-
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, bool without_witness, const CTxUndo* txundo, TxVerbosity verbosity)
171+
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex, const CTxUndo* txundo, TxVerbosity verbosity)
176172
{
177173
CHECK_NONFATAL(verbosity >= TxVerbosity::SHOW_DETAILS);
178174

@@ -268,6 +264,6 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
268264
}
269265

270266
if (include_hex) {
271-
entry.pushKV("hex", EncodeHexTx(tx, without_witness)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction".
267+
entry.pushKV("hex", EncodeHexTx(tx)); // The hex-encoded transaction. Used the name "hex" to be consistent with the verbose output of "getrawtransaction".
272268
}
273269
}

src/init.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ void SetupServerArgs(ArgsManager& argsman)
655655
argsman.AddArg("-rpccookiefile=<loc>", "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)", ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
656656
argsman.AddArg("-rpcpassword=<pw>", "Password for JSON-RPC connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC);
657657
argsman.AddArg("-rpcport=<port>", strprintf("Listen for JSON-RPC connections on <port> (default: %u, testnet: %u, signet: %u, regtest: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort(), signetBaseParams->RPCPort(), regtestBaseParams->RPCPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::RPC);
658-
argsman.AddArg("-rpcserialversion", strprintf("Sets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) (DEPRECATED) or segwit(1) (default: %d)", DEFAULT_RPC_SERIALIZE_VERSION), ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
659658
argsman.AddArg("-rpcservertimeout=<n>", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC);
660659
argsman.AddArg("-rpcthreads=<n>", strprintf("Set the number of threads to service RPC calls (default: %d)", DEFAULT_HTTP_THREADS), ArgsManager::ALLOW_ANY, OptionsCategory::RPC);
661660
argsman.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::RPC);
@@ -1025,16 +1024,6 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10251024
if (args.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS))
10261025
nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM);
10271026

1028-
if (args.GetIntArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
1029-
return InitError(Untranslated("rpcserialversion must be non-negative."));
1030-
1031-
if (args.GetIntArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
1032-
return InitError(Untranslated("Unknown rpcserialversion requested."));
1033-
1034-
if (args.GetIntArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0 && !IsDeprecatedRPCEnabled("serialversion")) {
1035-
return InitError(Untranslated("-rpcserialversion=0 is deprecated and will be removed in the future. Specify -deprecatedrpc=serialversion to allow anyway."));
1036-
}
1037-
10381027
// Also report errors from parsing before daemonization
10391028
{
10401029
kernel::Notifications notifications{};

src/interfaces/chain.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,6 @@ class Chain
335335
//! Run function after given number of seconds. Cancel any previous calls with same name.
336336
virtual void rpcRunLater(const std::string& name, std::function<void()> fn, int64_t seconds) = 0;
337337

338-
//! Current RPC serialization flags.
339-
virtual bool rpcSerializationWithoutWitness() = 0;
340-
341338
//! Get settings value.
342339
virtual common::SettingsValue getSetting(const std::string& arg) = 0;
343340

src/node/interfaces.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ class ChainImpl : public Chain
777777
{
778778
RPCRunLater(name, std::move(fn), seconds);
779779
}
780-
bool rpcSerializationWithoutWitness() override { return RPCSerializationWithoutWitness(); }
781780
common::SettingsValue getSetting(const std::string& name) override
782781
{
783782
return args().GetSetting(name);

src/rest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static bool rest_block(const std::any& context,
316316
switch (rf) {
317317
case RESTResponseFormat::BINARY: {
318318
DataStream ssBlock;
319-
ssBlock << RPCTxSerParams(block);
319+
ssBlock << TX_WITH_WITNESS(block);
320320
std::string binaryBlock = ssBlock.str();
321321
req->WriteHeader("Content-Type", "application/octet-stream");
322322
req->WriteReply(HTTP_OK, binaryBlock);
@@ -325,7 +325,7 @@ static bool rest_block(const std::any& context,
325325

326326
case RESTResponseFormat::HEX: {
327327
DataStream ssBlock;
328-
ssBlock << RPCTxSerParams(block);
328+
ssBlock << TX_WITH_WITNESS(block);
329329
std::string strHex = HexStr(ssBlock) + "\n";
330330
req->WriteHeader("Content-Type", "text/plain");
331331
req->WriteReply(HTTP_OK, strHex);
@@ -722,7 +722,7 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string
722722
switch (rf) {
723723
case RESTResponseFormat::BINARY: {
724724
DataStream ssTx;
725-
ssTx << RPCTxSerParams(tx);
725+
ssTx << TX_WITH_WITNESS(tx);
726726

727727
std::string binaryTx = ssTx.str();
728728
req->WriteHeader("Content-Type", "application/octet-stream");
@@ -732,7 +732,7 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string
732732

733733
case RESTResponseFormat::HEX: {
734734
DataStream ssTx;
735-
ssTx << RPCTxSerParams(tx);
735+
ssTx << TX_WITH_WITNESS(tx);
736736

737737
std::string strHex = HexStr(ssTx) + "\n";
738738
req->WriteHeader("Content-Type", "text/plain");

src/rpc/blockchain.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn
187187
// coinbase transaction (i.e. i == 0) doesn't have undo data
188188
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
189189
UniValue objTx(UniValue::VOBJ);
190-
TxToUniv(*tx, /*block_hash=*/uint256(), /*entry=*/objTx, /*include_hex=*/true, /*without_witness=*/RPCSerializationWithoutWitness(), txundo, verbosity);
190+
TxToUniv(*tx, /*block_hash=*/uint256(), /*entry=*/objTx, /*include_hex=*/true, txundo, verbosity);
191191
txs.push_back(objTx);
192192
}
193193
break;
@@ -736,10 +736,9 @@ static RPCHelpMan getblock()
736736

737737
const CBlock block{GetBlockChecked(chainman.m_blockman, *pblockindex)};
738738

739-
if (verbosity <= 0)
740-
{
739+
if (verbosity <= 0) {
741740
DataStream ssBlock;
742-
ssBlock << RPCTxSerParams(block);
741+
ssBlock << TX_WITH_WITNESS(block);
743742
std::string strHex = HexStr(ssBlock);
744743
return strHex;
745744
}

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static RPCHelpMan generateblock()
399399
obj.pushKV("hash", block_out->GetHash().GetHex());
400400
if (!process_new_block) {
401401
DataStream block_ser;
402-
block_ser << RPCTxSerParams(*block_out);
402+
block_ser << TX_WITH_WITNESS(*block_out);
403403
obj.pushKV("hex", HexStr(block_ser));
404404
}
405405
return obj;

src/rpc/rawtransaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
6262
// Blockchain contextual information (confirmations and blocktime) is not
6363
// available to code in bitcoin-common, so we query them here and push the
6464
// data into the returned UniValue.
65-
TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, RPCSerializationWithoutWitness(), txundo, verbosity);
65+
TxToUniv(tx, /*block_hash=*/uint256(), entry, /*include_hex=*/true, txundo, verbosity);
6666

6767
if (!hashBlock.IsNull()) {
6868
LOCK(cs_main);
@@ -383,7 +383,7 @@ static RPCHelpMan getrawtransaction()
383383
}
384384

385385
if (verbosity <= 0) {
386-
return EncodeHexTx(*tx, /*without_witness=*/RPCSerializationWithoutWitness());
386+
return EncodeHexTx(*tx);
387387
}
388388

389389
UniValue result(UniValue::VOBJ);

src/rpc/server.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,4 @@ void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nS
597597
deadlineTimers.emplace(name, std::unique_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000)));
598598
}
599599

600-
bool RPCSerializationWithoutWitness()
601-
{
602-
return (gArgs.GetIntArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0);
603-
}
604-
605600
CRPCTable tableRPC;

0 commit comments

Comments
 (0)