MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / cutOutCodesep

Method cutOutCodesep

modules/ecash-lib/src/script.ts:123–136  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 3

script.test.tsFile · 0.80
sigHashPreimageMethod · 0.80
updateScriptLenMethod · 0.80

Calls 2

opsMethod · 0.95
nextMethod · 0.45

Tested by

no test coverage detected