| 295 | } |
| 296 | |
| 297 | Value 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 | |
| 338 | Value invalidateblock(const Array& params, bool fHelp) { |
| 339 | if (fHelp || params.size() != 1) { |
nothing calls this directly
no test coverage detected