Skip to content

Commit 0e62637

Browse files
committed
Disable some more RPC with helpful message when in bitcoin mode
1 parent 1e5da20 commit 0e62637

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.");
@@ -1198,6 +1202,10 @@ UniValue getcompactsketch(const JSONRPCRequest& request)
11981202
}
11991203
}.ToString());
12001204

1205+
if (!g_con_elementsmode) {
1206+
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>`");
1207+
}
1208+
12011209
CBlock block;
12021210
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
12031211
CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1236,6 +1244,10 @@ UniValue consumecompactsketch(const JSONRPCRequest& request)
12361244
}
12371245
}.ToString());
12381246

1247+
if (!g_con_elementsmode) {
1248+
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>`");
1249+
}
1250+
12391251
UniValue ret(UniValue::VOBJ);
12401252

12411253
std::vector<unsigned char> compact_block_bytes(ParseHex(request.params[0].get_str()));
@@ -1305,6 +1317,10 @@ UniValue consumegetblocktxn(const JSONRPCRequest& request)
13051317
}
13061318
}.ToString());
13071319

1320+
if (!g_con_elementsmode) {
1321+
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>`");
1322+
}
1323+
13081324
CBlock block;
13091325
std::vector<unsigned char> block_bytes(ParseHex(request.params[0].get_str()));
13101326
CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1350,6 +1366,10 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
13501366
}
13511367
}.ToString());
13521368

1369+
if (!g_con_elementsmode) {
1370+
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>`");
1371+
}
1372+
13531373
// Compact block
13541374
std::vector<unsigned char> compact_block_bytes(ParseHex(request.params[0].get_str()));
13551375
CDataStream ssCompactBlock(compact_block_bytes, SER_NETWORK, PROTOCOL_VERSION);
@@ -1404,6 +1424,10 @@ UniValue testproposedblock(const JSONRPCRequest& request)
14041424
}
14051425
}.ToString());
14061426

1427+
if (!g_con_elementsmode) {
1428+
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>`");
1429+
}
1430+
14071431
CBlock block;
14081432
if (!DecodeHexBlk(block, request.params[0].get_str()))
14091433
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
@@ -6337,6 +6337,10 @@ UniValue listissuances(const JSONRPCRequest& request)
63376337
},
63386338
}.ToString());
63396339

6340+
if (!g_con_elementsmode) {
6341+
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>`");
6342+
}
6343+
63406344
auto locked_chain = pwallet->chain().lock();
63416345
LOCK(pwallet->cs_wallet);
63426346

@@ -6424,6 +6428,10 @@ UniValue destroyamount(const JSONRPCRequest& request)
64246428
},
64256429
}.ToString());
64266430

6431+
if (!g_con_elementsmode) {
6432+
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>`");
6433+
}
6434+
64276435
auto locked_chain = pwallet->chain().lock();
64286436
LOCK(pwallet->cs_wallet);
64296437

0 commit comments

Comments
 (0)