Skip to content

Commit 816ef0b

Browse files
committed
Disable some more RPC with helpful message when in bitcoin mode
1 parent ee14d88 commit 816ef0b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/rpc/mining.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,10 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
10241024
}
10251025
}.ToString());
10261026

1027+
if (!g_con_elementsmode) {
1028+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1029+
}
1030+
10271031
int required_wait = !request.params[0].isNull() ? request.params[0].get_int() : 0;
10281032
if (required_wait < 0) {
10291033
throw JSONRPCError(RPC_INVALID_PARAMETER, "min_tx_age must be non-negative.");
@@ -1200,6 +1204,10 @@ UniValue getcompactsketch(const JSONRPCRequest& request)
12001204
}
12011205
}.ToString());
12021206

1207+
if (!g_con_elementsmode) {
1208+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1209+
}
1210+
12031211
CBlock block;
12041212
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
12051213
CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1238,6 +1246,10 @@ UniValue consumecompactsketch(const JSONRPCRequest& request)
12381246
}
12391247
}.ToString());
12401248

1249+
if (!g_con_elementsmode) {
1250+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1251+
}
1252+
12411253
UniValue ret(UniValue::VOBJ);
12421254

12431255
std::vector<unsigned char> compact_block_bytes(ParseHex(request.params[0].get_str()));
@@ -1307,6 +1319,10 @@ UniValue consumegetblocktxn(const JSONRPCRequest& request)
13071319
}
13081320
}.ToString());
13091321

1322+
if (!g_con_elementsmode) {
1323+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1324+
}
1325+
13101326
CBlock block;
13111327
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
13121328
CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1352,6 +1368,10 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
13521368
}
13531369
}.ToString());
13541370

1371+
if (!g_con_elementsmode) {
1372+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1373+
}
1374+
13551375
// Compact block
13561376
std::vector<unsigned char> compact_block_bytes(ParseHex(request.params[0].get_str()));
13571377
CDataStream ssCompactBlock(compact_block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1406,6 +1426,10 @@ UniValue testproposedblock(const JSONRPCRequest& request)
14061426
}
14071427
}.ToString());
14081428

1429+
if (!g_con_elementsmode) {
1430+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
1431+
}
1432+
14091433
CBlock block;
14101434
if (!DecodeHexBlk(block, request.params[0].get_str()))
14111435
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");

src/wallet/rpcwallet.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6350,6 +6350,10 @@ UniValue listissuances(const JSONRPCRequest& request)
63506350
},
63516351
}.ToString());
63526352

6353+
if (!g_con_elementsmode) {
6354+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
6355+
}
6356+
63536357
auto locked_chain = pwallet->chain().lock();
63546358
LOCK(pwallet->cs_wallet);
63556359

@@ -6437,6 +6441,10 @@ UniValue destroyamount(const JSONRPCRequest& request)
64376441
},
64386442
}.ToString());
64396443

6444+
if (!g_con_elementsmode) {
6445+
throw JSONRPCError(RPC_INVALID_PARAMETER, "This RPC cannot be used in bitcoin compatibility mode. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
6446+
}
6447+
64406448
auto locked_chain = pwallet->chain().lock();
64416449
LOCK(pwallet->cs_wallet);
64426450

0 commit comments

Comments
 (0)