Skip to content

Commit

Permalink
[trello.com/c/GCrmAWok] OP codes fix
Browse files Browse the repository at this point in the history
  • Loading branch information
just-software-dev committed Jun 12, 2023
1 parent afb15f9 commit b185d90
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions BitcoinKit/Sources/BitcoinKit/Scripts/Opcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@ public enum OpCode: OpCodeProtocol {
// swiftlint:disable:next line_length
case OP_0, OP_FALSE, OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4, OP_1NEGATE, OP_RESERVED, OP_1, OP_TRUE, OP_2, OP_3, OP_4, OP_5, OP_6, OP_7, OP_8, OP_9, OP_10, OP_11, OP_12, OP_13, OP_14, OP_15, OP_16, OP_NOP, OP_VER, OP_IF, OP_NOTIF, OP_VERIF, OP_VERNOTIF, OP_ELSE, OP_ENDIF, OP_VERIFY, OP_RETURN, OP_TOALTSTACK, OP_FROMALTSTACK, OP_2DROP, OP_2DUP, OP_3DUP, OP_2OVER, OP_2ROT, OP_2SWAP, OP_IFDUP, OP_DEPTH, OP_DROP, OP_DUP, OP_NIP, OP_OVER, OP_PICK, OP_ROLL, OP_ROT, OP_SWAP, OP_TUCK, OP_CAT, OP_SIZE, OP_SPLIT, OP_NUM2BIN, OP_BIN2NUM, OP_INVERT, OP_AND, OP_OR, OP_XOR, OP_EQUAL, OP_EQUALVERIFY, OP_RESERVED1, OP_RESERVED2, OP_1ADD, OP_1SUB, OP_2MUL, OP_2DIV, OP_NEGATE, OP_ABS, OP_NOT, OP_0NOTEQUAL, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_LSHIFT, OP_RSHIFT, OP_BOOLAND, OP_BOOLOR, OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_LESSTHAN, OP_GREATERTHAN, OP_LESSTHANOREQUAL, OP_GREATERTHANOREQUAL, OP_MIN, OP_MAX, OP_WITHIN, OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256, OP_CODESEPARATOR, OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY, OP_CHECKLOCKTIMEVERIFY, OP_CHECKSEQUENCEVERIFY, OP_PUBKEYHASH, OP_PUBKEY, OP_INVALIDOPCODE, OP_NOP1, OP_NOP4, OP_NOP5, OP_NOP6, OP_NOP7, OP_NOP8, OP_NOP9, OP_NOP10

static let p2pkhStart = Data(from: [OpCode.OP_DUP, OpCode.OP_HASH160])
static let p2pkhFinish = Data([OpCode.OP_EQUALVERIFY.value, OpCode.checkSig])
static let p2pkFinish = Data([OpCode.checkSig])
static let p2shStart = Data(from: [OpCode.OP_HASH160])
static let p2shFinish = Data(from: [OpCode.OP_EQUAL])
static let p2pkhStart = Data([OpCode.OP_DUP.value, OpCode.OP_HASH160.value])
static let p2pkhFinish = Data([OpCode.OP_EQUALVERIFY.value, OpCode.OP_CHECKSIG.value])
static let p2pkFinish = Data([OpCode.OP_CHECKSIG.value])
static let p2shStart = Data([OpCode.OP_HASH160.value])
static let p2shFinish = Data([OpCode.OP_EQUAL.value])

static let pFromShCodes = [
OpCode.OP_CHECKSIG.value,
OpCode.OP_CHECKSIGVERIFY.value,
OpCode.OP_CHECKMULTISIG.value,
OpCode.OP_CHECKMULTISIGVERIFY.value
]

static let pushData1: UInt8 = 0x4c
static let pushData2: UInt8 = 0x4d
static let pushData4: UInt8 = 0x4e
static let pFromShCodes = [checkSig, checkSigVerify, checkMultiSig, checkMultiSigVerify]
static let checkSig: UInt8 = 0xAC
static let checkSigVerify: UInt8 = 0xAD
static let checkMultiSig: UInt8 = 0xAE
static let checkMultiSigVerify: UInt8 = 0xAF

private var opcode: OpCodeProtocol {
switch self {
Expand Down

0 comments on commit b185d90

Please sign in to comment.