| 488 | } |
| 489 | |
| 490 | bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const |
| 491 | { |
| 492 | opcodeRet = OP_INVALIDOPCODE; |
| 493 | if (pvchRet) |
| 494 | pvchRet->clear(); |
| 495 | if (pc >= end()) |
| 496 | return false; |
| 497 | |
| 498 | // Read instruction |
| 499 | if (end() - pc < 1) |
| 500 | return false; |
| 501 | unsigned int opcode = *pc++; |
| 502 | |
| 503 | // Immediate operand |
| 504 | if (opcode <= OP_PUSHDATA4) |
| 505 | { |
| 506 | unsigned int nSize = 0; |
| 507 | if (opcode < OP_PUSHDATA1) |
| 508 | { |
| 509 | nSize = opcode; |
| 510 | } |
| 511 | else if (opcode == OP_PUSHDATA1) |
| 512 | { |
| 513 | if (end() - pc < 1) |
| 514 | return false; |
| 515 | nSize = *pc++; |
| 516 | } |
| 517 | else if (opcode == OP_PUSHDATA2) |
| 518 | { |
| 519 | if (end() - pc < 2) |
| 520 | return false; |
| 521 | nSize = ReadLE16(&pc[0]); |
| 522 | pc += 2; |
| 523 | } |
| 524 | else if (opcode == OP_PUSHDATA4) |
| 525 | { |
| 526 | if (end() - pc < 4) |
| 527 | return false; |
| 528 | nSize = ReadLE32(&pc[0]); |
| 529 | pc += 4; |
| 530 | } |
| 531 | if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) |
| 532 | return false; |
| 533 | if (pvchRet) |
| 534 | pvchRet->assign(pc, pc + nSize); |
| 535 | pc += nSize; |
| 536 | } |
| 537 | |
| 538 | opcodeRet = (opcodetype)opcode; |
| 539 | return true; |
| 540 | } |
| 541 | |
| 542 | /** Encode/decode small integers: */ |
| 543 | static int DecodeOP_N(opcodetype opcode) |
no test coverage detected