* Instantiate a pushdata opcode from symbolic name. * @example * Opcode.fromSymbol('checksequenceverify') * @param {String} name * @returns {Opcode}
(name)
| 549 | */ |
| 550 | |
| 551 | static fromSymbol(name) { |
| 552 | assert(typeof name === 'string'); |
| 553 | assert(name.length > 0); |
| 554 | |
| 555 | if (name.charCodeAt(0) & 32) |
| 556 | name = name.toUpperCase(); |
| 557 | |
| 558 | if (!/^OP_/.test(name)) |
| 559 | name = `OP_${name}`; |
| 560 | |
| 561 | const op = common.opcodes[name]; |
| 562 | |
| 563 | if (op != null) |
| 564 | return this.fromOp(op); |
| 565 | |
| 566 | assert(/^OP_0X/.test(name), 'Unknown opcode.'); |
| 567 | assert(name.length === 7, 'Unknown opcode.'); |
| 568 | |
| 569 | const value = parseInt(name.substring(5), 16); |
| 570 | |
| 571 | assert((value & 0xff) === value, 'Unknown opcode.'); |
| 572 | |
| 573 | return this.fromOp(value); |
| 574 | } |
| 575 | |
| 576 | /** |
| 577 | * Instantiate opcode from buffer reader. |
no test coverage detected