Skip to content

Commit

Permalink
Merge #1181: Return error, when using bitcore RPCs without addrindex
Browse files Browse the repository at this point in the history
c7d1951 Return error, when using bitcore RPCs without addrindex (dexX7)

Pull request description:

  When the address index (bitcore patch) isn't enabled, return an error, when using the related RPCs.

Tree-SHA512: 13aaeab45ae4b74ddb376549d2d4f8240454b934a097c478759825ea321b96c2ebea77c3193251f21abc590f19240f24e77b3f14ab0fe818016ab9e276d4d6ba
  • Loading branch information
dexX7 committed Oct 8, 2020
2 parents 4bd249e + c7d1951 commit 6998e42
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ UniValue getaddressdeltas(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

UniValue startValue = find_value(request.params[0].get_obj(), "start");
UniValue endValue = find_value(request.params[0].get_obj(), "end");
Expand Down Expand Up @@ -297,6 +300,10 @@ UniValue getaddressbalance(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

std::vector<std::pair<uint256, int> > addresses;

if (!getAddressesFromParams(request.params, addresses)) {
Expand Down Expand Up @@ -370,6 +377,10 @@ UniValue getaddressutxos(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

bool includeChainInfo = false;
if (request.params[0].isObject()) {
UniValue chainInfo = find_value(request.params[0].get_obj(), "chainInfo");
Expand Down Expand Up @@ -457,6 +468,10 @@ UniValue getaddressmempool(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

std::vector<std::pair<uint256, int> > addresses;

if (!getAddressesFromParams(request.params, addresses)) {
Expand Down Expand Up @@ -531,6 +546,10 @@ UniValue getblockhashes(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

unsigned int high = request.params[0].get_int();
unsigned int low = request.params[1].get_int();
bool fActiveOnly = false;
Expand Down Expand Up @@ -598,6 +617,10 @@ UniValue getspentinfo(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

UniValue txidValue = find_value(request.params[0].get_obj(), "txid");
UniValue indexValue = find_value(request.params[0].get_obj(), "index");

Expand Down Expand Up @@ -656,6 +679,10 @@ UniValue getaddresstxids(const JSONRPCRequest& request)
},
}.ToString());

if (!fAddressIndex) {
throw JSONRPCError(RPC_MISC_ERROR, "Address index not enabled");
}

std::vector<std::pair<uint256, int> > addresses;

if (!getAddressesFromParams(request.params, addresses)) {
Expand Down

0 comments on commit 6998e42

Please sign in to comment.