本文整理汇总了C++中CBlock::GetTxIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::GetTxIndex方法的具体用法?C++ CBlock::GetTxIndex怎么用?C++ CBlock::GetTxIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::GetTxIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsTxInTipBlock
bool SysTestBase::IsTxInTipBlock(const uint256& txHash) {
CBlockIndex* pindex = chainActive.Tip();
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return false;
block.BuildMerkleTree();
std::tuple<bool, int> ret = block.GetTxIndex(txHash);
if (!std::get<0>(ret)) {
return false;
}
return true;
}
示例2: GetTxIndexInBlock
bool GetTxIndexInBlock(const uint256& txHash, int& nIndex) {
CBlockIndex* pindex = chainActive.Tip();
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return false;
block.BuildMerkleTree();
std::tuple<bool,int> ret = block.GetTxIndex(txHash);
if (!std::get<0>(ret)) {
return false;
}
nIndex = std::get<1>(ret);
return true;
}
示例3: getscriptid
Value getscriptid(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1) {
throw runtime_error("getscriptid \n"
"\nreturn an object containing regid and script\n"
"\nArguments:\n"
"1. txhash (string, required) the transaction hash.\n"
"\nResult:\n"
"\nExamples:\n"
+ HelpExampleCli("getscriptid", "5zQPcC1YpFMtwxiH787pSXanUECoGsxUq3KZieJxVG")
+ HelpExampleRpc("getscriptid","5zQPcC1YpFMtwxiH787pSXanUECoGsxUq3KZieJxVG"));
}
uint256 txhash(uint256S(params[0].get_str()));
int nIndex = 0;
int BlockHeight =GetTxComfirmHigh(txhash, *pScriptDBTip) ;
if(BlockHeight > chainActive.Height())
{
throw runtime_error("height larger than tip block \n");
}
else if(BlockHeight == -1){
throw runtime_error("tx hash unconfirmed \n");
}
CBlockIndex* pindex = chainActive[BlockHeight];
CBlock block;
if (!ReadBlockFromDisk(block, pindex))
return false;
block.BuildMerkleTree();
std::tuple<bool,int> ret = block.GetTxIndex(txhash);
if (!std::get<0>(ret)) {
throw runtime_error("tx not exit in block");
}
nIndex = std::get<1>(ret);
CRegID striptID(BlockHeight, nIndex);
Object result;
result.push_back(Pair("regid:", striptID.ToString()));
result.push_back(Pair("script", HexStr(striptID.GetVec6())));
return result;
}