MCPcopy
hub / github.com/bcoin-org/bcoin / fromSymbol

Method fromSymbol

lib/script/opcode.js:551–574  ·  view source on GitHub ↗

* Instantiate a pushdata opcode from symbolic name. * @example * Opcode.fromSymbol('checksequenceverify') * @param {String} name * @returns {Opcode}

(name)

Source from the content-addressed store, hash-verified

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.

Callers 9

setSymMethod · 0.80
pushSymMethod · 0.80
unshiftSymMethod · 0.80
insertSymMethod · 0.80
mineCSVFunction · 0.80
node-test.jsFile · 0.80
mineCSVFunction · 0.80
chain-test.jsFile · 0.80
script-test.jsFile · 0.80

Calls 2

fromOpMethod · 0.95
testMethod · 0.45

Tested by

no test coverage detected