• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ valtype类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中valtype的典型用法代码示例。如果您正苦于以下问题:C++ valtype类的具体用法?C++ valtype怎么用?C++ valtype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了valtype类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: checkCanonicalSignature

void checkCanonicalSignature(const valtype &vchSig) {
    // See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623
    // A canonical signature exists of: <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
    // Where R and S are not negative (their first byte has its highest bit not set), and not
    // excessively padded (do not start with a 0 byte, unless an otherwise negative number follows,
    // in which case a single 0 byte is necessary and even required).
    if (vchSig.size() < 9)
        throw runtime_error("Non-canonical signature: too short");
    if (vchSig.size() > 73)
        throw runtime_error("Non-canonical signature: too long");
    unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY));
    if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE)
        throw runtime_error("Non-canonical signature: unknown hashtype byte");
    if (vchSig[0] != 0x30)
        throw runtime_error("Non-canonical signature: wrong type");
    if (vchSig[1] != vchSig.size()-3)
        throw runtime_error("Non-canonical signature: wrong length marker");
    unsigned int nLenR = vchSig[3];
    if (5 + nLenR >= vchSig.size())
        throw runtime_error("Non-canonical signature: S length misplaced");
    unsigned int nLenS = vchSig[5+nLenR];
    if ((unsigned long)(nLenR+nLenS+7) != vchSig.size())
        throw runtime_error("Non-canonical signature: R+S length mismatch");
    
    const unsigned char *R = &vchSig[4];
    if (R[-2] != 0x02)
        throw runtime_error("Non-canonical signature: R value type mismatch");
    if (nLenR == 0)
        throw runtime_error("Non-canonical signature: R length is zero");
    if (R[0] & 0x80)
        throw runtime_error("Non-canonical signature: R value negative");
    if (nLenR > 1 && (R[0] == 0x00) && !(R[1] & 0x80))
        throw runtime_error("Non-canonical signature: R value excessively padded");
    
    const unsigned char *S = &vchSig[6+nLenR];
    if (S[-2] != 0x02)
        throw runtime_error("Non-canonical signature: S value type mismatch");
    if (nLenS == 0)
        throw runtime_error("Non-canonical signature: S length is zero");
    if (S[0] & 0x80)
        throw runtime_error("Non-canonical signature: S value negative");
    if (nLenS > 1 && (S[0] == 0x00) && !(S[1] & 0x80))
        throw runtime_error("Non-canonical signature: S value excessively padded");
}
开发者ID:John-Kenney,项目名称:libcoin,代码行数:44,代码来源:Script.cpp


示例2: CheckMinimalPush

bool static CheckMinimalPush(const valtype& data, opcodetype opcode) {
    if (data.size() == 0) {
        // Could have used OP_0.
        return opcode == OP_0;
    } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) {
        // Could have used OP_1 .. OP_16.
        return opcode == OP_1 + (data[0] - 1);
    } else if (data.size() == 1 && data[0] == 0x81) {
        // Could have used OP_1NEGATE.
        return opcode == OP_1NEGATE;
    } else if (data.size() <= 75) {
        // Could have used a direct push (opcode indicating number of bytes pushed + those bytes).
        return opcode == data.size();
    } else if (data.size() <= 255) {
        // Could have used OP_PUSHDATA.
        return opcode == OP_PUSHDATA1;
    } else if (data.size() <= 65535) {
        // Could have used OP_PUSHDATA2.
        return opcode == OP_PUSHDATA2;
    }
    return true;
}
开发者ID:CFEnergy,项目名称:CFEnergyd,代码行数:22,代码来源:interpreter.cpp


示例3: IsDERSignature

/**
 * A canonical signature exists of: <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype>
 * Where R and S are not negative (their first byte has its highest bit not set), and not
 * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows,
 * in which case a single 0 byte is necessary and even required).
 * 
 * See https://bitcredittalk.org/index.php?topic=8392.msg127623#msg127623
 */
bool static IsDERSignature(const valtype &vchSig) {

    if (vchSig.size() < 9) {
        //  Non-canonical signature: too short
        return false;
    }
    if (vchSig.size() > 73) {
        // Non-canonical signature: too long
        return false;
    }
    if (vchSig[0] != 0x30) {
        //  Non-canonical signature: wrong type
        return false;
    }
    if (vchSig[1] != vchSig.size()-3) {
        //  Non-canonical signature: wrong length marker
        return false;
    }
    unsigned int nLenR = vchSig[3];
    if (5 + nLenR >= vchSig.size()) {
        //  Non-canonical signature: S length misplaced
        return false;
    }
    unsigned int nLenS = vchSig[5+nLenR];
    if ((unsigned long)(nLenR+nLenS+7) != vchSig.size()) {
        //  Non-canonical signature: R+S length mismatch
        return false;
    }

    const unsigned char *R = &vchSig[4];
    if (R[-2] != 0x02) {
        //  Non-canonical signature: R value type mismatch
        return false;
    }
    if (nLenR == 0) {
        //  Non-canonical signature: R length is zero
        return false;
    }
    if (R[0] & 0x80) {
        //  Non-canonical signature: R value negative
        return false;
    }
    if (nLenR > 1 && (R[0] == 0x00) && !(R[1] & 0x80)) {
        //  Non-canonical signature: R value excessively padded
        return false;
    }

    const unsigned char *S = &vchSig[6+nLenR];
    if (S[-2] != 0x02) {
        //  Non-canonical signature: S value type mismatch
        return false;
    }
    if (nLenS == 0) {
        //  Non-canonical signature: S length is zero
        return false;
    }
    if (S[0] & 0x80) {
        //  Non-canonical signature: S value negative
        return false;
    }
    if (nLenS > 1 && (S[0] == 0x00) && !(S[1] & 0x80)) {
        //  Non-canonical signature: S value excessively padded
        return false;
    }
    return true;
}
开发者ID:JoshuaAmsden,项目名称:bicreditsnew,代码行数:74,代码来源:interpreter.cpp



注:本文中的valtype类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ value类代码示例发布时间:2022-05-31
下一篇:
C++ valarray类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap