From 096f2172c6a93473ce55e94f93368f281db4ad5e Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Sun, 3 Apr 2022 21:58:53 +0200 Subject: [PATCH] more direct opcode comparison --- backend/src/api/bitcoin/bitcoin-api.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/src/api/bitcoin/bitcoin-api.ts b/backend/src/api/bitcoin/bitcoin-api.ts index ec786593e..17808d8bc 100644 --- a/backend/src/api/bitcoin/bitcoin-api.ts +++ b/backend/src/api/bitcoin/bitcoin-api.ts @@ -328,15 +328,16 @@ class BitcoinApi implements AbstractBitcoinApi { } else { const opcode = bitcoinjs.script.toASM([ op ]); if (opcode && op < 0xfd) { - if (opcode === 'OP_1NEGATE') { + if (op === 0x4f) { b.push('OP_PUSHNUM_NEG1'); - } else if (/^OP_(\d+)$/.test(opcode) && opcode !== 'OP_0') { + } else if (/^OP_(\d+)$/.test(opcode) && op !== 0x00) { b.push(opcode.replace(/^OP_(\d+)$/, 'OP_PUSHNUM_$1')); + } else if (op === 0xb1) { + b.push('OP_CLTV'); + } else if (op === 0xb2) { + b.push('OP_CSV'); } else { - b.push(opcode - .replace('OP_CHECKSEQUENCEVERIFY', 'OP_CSV') - .replace('OP_CHECKLOCKTIMEVERIFY', 'OP_CLTV') - ); + b.push(opcode); } } else { b.push('OP_RETURN_' + op);