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

Method fromPubkey

lib/script/script.js:1412–1427  ·  view source on GitHub ↗

* Inject properties from a pay-to-pubkey script. * @private * @param {Buffer} key

(key)

Source from the content-addressed store, hash-verified

1410 */
1411
1412 fromPubkey(key) {
1413 assert(Buffer.isBuffer(key) && (key.length === 33 || key.length === 65));
1414
1415 this.raw = Buffer.allocUnsafe(1 + key.length + 1);
1416 this.raw[0] = key.length;
1417 key.copy(this.raw, 1);
1418 this.raw[1 + key.length] = opcodes.OP_CHECKSIG;
1419
1420 key = this.raw.slice(1, 1 + key.length);
1421
1422 this.code.length = 0;
1423 this.code.push(Opcode.fromPush(key));
1424 this.code.push(Opcode.fromOp(opcodes.OP_CHECKSIG));
1425
1426 return this;
1427 }
1428
1429 /**
1430 * Create a pay-to-pubkey script.

Callers 5

decompressScriptFunction · 0.80
decompressScriptFunction · 0.80
mempool-test.jsFile · 0.80
createGenesisBlockFunction · 0.80
randomPubkeyFunction · 0.80

Calls 3

fromPushMethod · 0.80
fromOpMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected