MCPcopy Index your code
hub / github.com/bcoin-org/bcoin / removeSeparators

Method removeSeparators

lib/script/script.js:472–504  ·  view source on GitHub ↗

* Get the script's "subscript" starting at a separator. * Remove all OP_CODESEPARATORs if present. This bizarre * behavior is necessary for signing and verification when * code separators are present. * @returns {Script} Subscript.

()

Source from the content-addressed store, hash-verified

470 */
471
472 removeSeparators() {
473 let found = false;
474
475 // Optimizing for the common case:
476 // Check for any separators first.
477 for (const op of this.code) {
478 if (op.value === -1)
479 break;
480
481 if (op.value === opcodes.OP_CODESEPARATOR) {
482 found = true;
483 break;
484 }
485 }
486
487 if (!found)
488 return this;
489
490 // Uncommon case: someone actually
491 // has a code separator. Go through
492 // and remove them all.
493 const script = new Script();
494
495 for (const op of this.code) {
496 if (op.value === -1)
497 break;
498
499 if (op.value !== opcodes.OP_CODESEPARATOR)
500 script.code.push(op);
501 }
502
503 return script.compile();
504 }
505
506 /**
507 * Execute and interpret the script.

Callers 2

signatureHashV0Method · 0.80
tx-test.jsFile · 0.80

Calls 2

compileMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected