MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / getcontractregid

Function getcontractregid

src/rpc/rpcblockchain.cpp:297–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297Value getcontractregid(const Array& params, bool fHelp) {
298 if (fHelp || params.size() != 1) {
299 throw runtime_error(
300 "getcontractregid\n"
301 "\nreturn an object with regid\n"
302 "\nArguments:\n"
303 "1. txid (string, required) the contract registration txid.\n"
304 "\nResult:\n"
305 "\nExamples:\n" +
306 HelpExampleCli("getcontractregid", "\"wNw1Rr8cHPerXXGt6yxEkAPHDXmzMiQBn4\"") + "\nAs json rpc\n" +
307 HelpExampleRpc("getcontractregid", "\"wNw1Rr8cHPerXXGt6yxEkAPHDXmzMiQBn4\""));
308 }
309
310 uint256 txid(uint256S(params[0].get_str()));
311
312 int index = 0;
313 int nBlockHeight = GetTxConfirmHeight(txid, *pCdMan->pBlockCache);
314 if (nBlockHeight > chainActive.Height()) {
315 throw runtime_error("height bigger than tip block");
316 } else if (-1 == nBlockHeight) {
317 throw runtime_error("tx unconfirmed");
318 }
319 CBlockIndex* pIndex = chainActive[nBlockHeight];
320 CBlock block;
321 if (!ReadBlockFromDisk(pIndex, block))
322 return false;
323
324 block.BuildMerkleTree();
325 std::tuple<bool,int> ret = block.GetTxIndex(txid);
326 if (!std::get<0>(ret)) {
327 throw runtime_error("tx not exit in block");
328 }
329
330 index = std::get<1>(ret);
331 CRegID regId(nBlockHeight, index);
332 Object result;
333 result.push_back(Pair("regid", regId.ToString()));
334 result.push_back(Pair("regid_hex", HexStr(regId.GetRegIdRaw())));
335 return result;
336}
337
338Value invalidateblock(const Array& params, bool fHelp) {
339 if (fHelp || params.size() != 1) {

Callers

nothing calls this directly

Calls 14

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
uint256SFunction · 0.85
GetTxConfirmHeightFunction · 0.85
ReadBlockFromDiskFunction · 0.85
PairClass · 0.85
HexStrFunction · 0.85
HeightMethod · 0.80
BuildMerkleTreeMethod · 0.80
GetTxIndexMethod · 0.80
push_backMethod · 0.80
GetRegIdRawMethod · 0.80

Tested by

no test coverage detected