/// <returns>Opcode name</returns>
public static string GetOpName(instruction opcode)
{
- switch (opcode)
- {
- // push value
- case instruction.OP_0:
- return "OP_0";
- case instruction.OP_PUSHDATA1:
- return "OP_PUSHDATA1";
- case instruction.OP_PUSHDATA2:
- return "OP_PUSHDATA2";
- case instruction.OP_PUSHDATA4:
- return "OP_PUSHDATA4";
- case instruction.OP_1NEGATE:
- return "OP_1NEGATE";
- case instruction.OP_RESERVED:
- return "OP_RESERVED";
- case instruction.OP_1:
- return "OP_1";
- case instruction.OP_2:
- return "OP_2";
- case instruction.OP_3:
- return "OP_3";
- case instruction.OP_4:
- return "OP_4";
- case instruction.OP_5:
- return "OP_5";
- case instruction.OP_6:
- return "OP_6";
- case instruction.OP_7:
- return "OP_7";
- case instruction.OP_8:
- return "OP_8";
- case instruction.OP_9:
- return "OP_9";
- case instruction.OP_10:
- return "OP_10";
- case instruction.OP_11:
- return "OP_11";
- case instruction.OP_12:
- return "OP_12";
- case instruction.OP_13:
- return "OP_13";
- case instruction.OP_14:
- return "OP_14";
- case instruction.OP_15:
- return "OP_15";
- case instruction.OP_16:
- return "OP_16";
-
- // control
- case instruction.OP_NOP:
- return "OP_NOP";
- case instruction.OP_VER:
- return "OP_VER";
- case instruction.OP_IF:
- return "OP_IF";
- case instruction.OP_NOTIF:
- return "OP_NOTIF";
- case instruction.OP_VERIF:
- return "OP_VERIF";
- case instruction.OP_VERNOTIF:
- return "OP_VERNOTIF";
- case instruction.OP_ELSE:
- return "OP_ELSE";
- case instruction.OP_ENDIF:
- return "OP_ENDIF";
- case instruction.OP_VERIFY:
- return "OP_VERIFY";
- case instruction.OP_RETURN:
- return "OP_RETURN";
-
- // stack ops
- case instruction.OP_TOALTSTACK:
- return "OP_TOALTSTACK";
- case instruction.OP_FROMALTSTACK:
- return "OP_FROMALTSTACK";
- case instruction.OP_2DROP:
- return "OP_2DROP";
- case instruction.OP_2DUP:
- return "OP_2DUP";
- case instruction.OP_3DUP:
- return "OP_3DUP";
- case instruction.OP_2OVER:
- return "OP_2OVER";
- case instruction.OP_2ROT:
- return "OP_2ROT";
- case instruction.OP_2SWAP:
- return "OP_2SWAP";
- case instruction.OP_IFDUP:
- return "OP_IFDUP";
- case instruction.OP_DEPTH:
- return "OP_DEPTH";
- case instruction.OP_DROP:
- return "OP_DROP";
- case instruction.OP_DUP:
- return "OP_DUP";
- case instruction.OP_NIP:
- return "OP_NIP";
- case instruction.OP_OVER:
- return "OP_OVER";
- case instruction.OP_PICK:
- return "OP_PICK";
- case instruction.OP_ROLL:
- return "OP_ROLL";
- case instruction.OP_ROT:
- return "OP_ROT";
- case instruction.OP_SWAP:
- return "OP_SWAP";
- case instruction.OP_TUCK:
- return "OP_TUCK";
-
- // splice ops
- case instruction.OP_CAT:
- return "OP_CAT";
- case instruction.OP_SUBSTR:
- return "OP_SUBSTR";
- case instruction.OP_LEFT:
- return "OP_LEFT";
- case instruction.OP_RIGHT:
- return "OP_RIGHT";
- case instruction.OP_SIZE:
- return "OP_SIZE";
-
- // bit logic
- case instruction.OP_INVERT:
- return "OP_INVERT";
- case instruction.OP_AND:
- return "OP_AND";
- case instruction.OP_OR:
- return "OP_OR";
- case instruction.OP_XOR:
- return "OP_XOR";
- case instruction.OP_EQUAL:
- return "OP_EQUAL";
- case instruction.OP_EQUALVERIFY:
- return "OP_EQUALVERIFY";
- case instruction.OP_RESERVED1:
- return "OP_RESERVED1";
- case instruction.OP_RESERVED2:
- return "OP_RESERVED2";
-
- // numeric
- case instruction.OP_1ADD:
- return "OP_1ADD";
- case instruction.OP_1SUB:
- return "OP_1SUB";
- case instruction.OP_2MUL:
- return "OP_2MUL";
- case instruction.OP_2DIV:
- return "OP_2DIV";
- case instruction.OP_NEGATE:
- return "OP_NEGATE";
- case instruction.OP_ABS:
- return "OP_ABS";
- case instruction.OP_NOT:
- return "OP_NOT";
- case instruction.OP_0NOTEQUAL:
- return "OP_0NOTEQUAL";
- case instruction.OP_ADD:
- return "OP_ADD";
- case instruction.OP_SUB:
- return "OP_SUB";
- case instruction.OP_MUL:
- return "OP_MUL";
- case instruction.OP_DIV:
- return "OP_DIV";
- case instruction.OP_MOD:
- return "OP_MOD";
- case instruction.OP_LSHIFT:
- return "OP_LSHIFT";
- case instruction.OP_RSHIFT:
- return "OP_RSHIFT";
- case instruction.OP_BOOLAND:
- return "OP_BOOLAND";
- case instruction.OP_BOOLOR:
- return "OP_BOOLOR";
- case instruction.OP_NUMEQUAL:
- return "OP_NUMEQUAL";
- case instruction.OP_NUMEQUALVERIFY:
- return "OP_NUMEQUALVERIFY";
- case instruction.OP_NUMNOTEQUAL:
- return "OP_NUMNOTEQUAL";
- case instruction.OP_LESSTHAN:
- return "OP_LESSTHAN";
- case instruction.OP_GREATERTHAN:
- return "OP_GREATERTHAN";
- case instruction.OP_LESSTHANOREQUAL:
- return "OP_LESSTHANOREQUAL";
- case instruction.OP_GREATERTHANOREQUAL:
- return "OP_GREATERTHANOREQUAL";
- case instruction.OP_MIN:
- return "OP_MIN";
- case instruction.OP_MAX:
- return "OP_MAX";
- case instruction.OP_WITHIN:
- return "OP_WITHIN";
-
- // crypto
- case instruction.OP_RIPEMD160:
- return "OP_RIPEMD160";
- case instruction.OP_SHA1:
- return "OP_SHA1";
- case instruction.OP_SHA256:
- return "OP_SHA256";
- case instruction.OP_HASH160:
- return "OP_HASH160";
- case instruction.OP_HASH256:
- return "OP_HASH256";
- case instruction.OP_CODESEPARATOR:
- return "OP_CODESEPARATOR";
- case instruction.OP_CHECKSIG:
- return "OP_CHECKSIG";
- case instruction.OP_CHECKSIGVERIFY:
- return "OP_CHECKSIGVERIFY";
- case instruction.OP_CHECKMULTISIG:
- return "OP_CHECKMULTISIG";
- case instruction.OP_CHECKMULTISIGVERIFY:
- return "OP_CHECKMULTISIGVERIFY";
-
- // expansion
- case instruction.OP_NOP1:
- return "OP_NOP1";
- case instruction.OP_NOP2:
- return "OP_NOP2";
- case instruction.OP_NOP3:
- return "OP_NOP3";
- case instruction.OP_NOP4:
- return "OP_NOP4";
- case instruction.OP_NOP5:
- return "OP_NOP5";
- case instruction.OP_NOP6:
- return "OP_NOP6";
- case instruction.OP_NOP7:
- return "OP_NOP7";
- case instruction.OP_NOP8:
- return "OP_NOP8";
- case instruction.OP_NOP9:
- return "OP_NOP9";
- case instruction.OP_NOP10:
- return "OP_NOP10";
-
- // template matching params
- case instruction.OP_SMALLINTEGER:
- return "OP_SMALLINTEGER";
- case instruction.OP_PUBKEYHASH:
- return "OP_PUBKEYHASH";
- case instruction.OP_PUBKEY:
- return "OP_PUBKEY";
- case instruction.OP_PUBKEYS:
- return "OP_PUBKEYS";
- case instruction.OP_SMALLDATA:
- return "OP_SMALLDATA";
-
- case instruction.OP_INVALIDOPCODE:
- return "OP_INVALIDOPCODE";
- default:
- return "OP_UNKNOWN";
- }
+ if (opcode == instruction.OP_0) // OP_0 and OP_FALSE are synonyms
+ return "OP_0";
+ if (opcode == instruction.OP_1) // OP_1 and OP_TRUE are synonyms
+ return "OP_1";
+
+ return Enum.GetName(typeof(instruction), opcode);
}
/// <summary>