* Find the n-th OP_CODESEPARATOR (0-based) and cut out the bytecode * following it. Required for signing BIP143 scripts that have an * OP_CODESEPARATOR. * * Throw an error if the n-th OP_CODESEPARATOR doesn't exist. * * Historically this opcode has been seen as obscure
(nCodesep: number)
| 121 | * If the covenant bytecode is 520 or so, this would save 519 bytes. |
| 122 | */ |
| 123 | public cutOutCodesep(nCodesep: number): Script { |
| 124 | const ops = this.ops(); |
| 125 | let op: Op | undefined; |
| 126 | let nCodesepsFound = 0; |
| 127 | while ((op = ops.next()) !== undefined) { |
| 128 | if (op == OP_CODESEPARATOR) { |
| 129 | if (nCodesepsFound == nCodesep) { |
| 130 | return new Script(this.bytecode.slice(ops.bytes.idx)); |
| 131 | } |
| 132 | nCodesepsFound++; |
| 133 | } |
| 134 | } |
| 135 | throw new Error('OP_CODESEPARATOR not found'); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Whether the Script is a P2SH Script. |
no test coverage detected