MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetOp2

Method GetOp2

src/script/script.h:562–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560 }
561
562 bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const
563 {
564 opcodeRet = OP_INVALIDOPCODE;
565 if (pvchRet)
566 pvchRet->clear();
567 if (pc >= end())
568 return false;
569
570 // Read instruction
571 if (end() - pc < 1)
572 return false;
573 unsigned int opcode = *pc++;
574
575 // Immediate operand
576 if (opcode <= OP_PUSHDATA4)
577 {
578 unsigned int nSize = 0;
579 if (opcode < OP_PUSHDATA1)
580 {
581 nSize = opcode;
582 }
583 else if (opcode == OP_PUSHDATA1)
584 {
585 if (end() - pc < 1)
586 return false;
587 nSize = *pc++;
588 }
589 else if (opcode == OP_PUSHDATA2)
590 {
591 if (end() - pc < 2)
592 return false;
593 nSize = 0;
594 memcpy(&nSize, &pc[0], 2);
595 pc += 2;
596 }
597 else if (opcode == OP_PUSHDATA4)
598 {
599 if (end() - pc < 4)
600 return false;
601 memcpy(&nSize, &pc[0], 4);
602 pc += 4;
603 }
604 if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize)
605 return false;
606 if (pvchRet)
607 pvchRet->assign(pc, pc + nSize);
608 pc += nSize;
609 }
610
611 opcodeRet = static_cast<opcodetype>(opcode);
612 return true;
613 }
614
615 /** Encode/decode small integers: */
616 static int DecodeOP_N(opcodetype opcode)

Callers 1

FormatScriptFunction · 0.80

Calls 4

endFunction · 0.85
memcpyFunction · 0.85
clearMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected