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; }
static bool verify(const CBigNum& bignum, const CScriptNum& scriptnum) { return bignum.getvch() == scriptnum.getvch() && bignum.getint() == scriptnum.getint(); }