* 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.
()
| 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. |
no test coverage detected