コード例 #1
0
ファイル: Block.cpp プロジェクト: dioptre/libcoin
int Block::getHeight() const {
    Script coinbase = getTransaction(0).getInput(0).signature();
    Script::const_iterator cbi = coinbase.begin();
    opcodetype opcode;
    std::vector<unsigned char> data;
    // We simply ignore the first opcode and data, however, it is the height...
    coinbase.getOp(cbi, opcode, data);
    if (opcode < OP_PUSHDATA1) {
        CBigNum height;
        height.setvch(data);
        int h = height.getint();
        return h;
    }
    return 0;
}
コード例 #2
0
static bool verify(const CBigNum& bignum, const CScriptNum& scriptnum)
{
    return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint();
}