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

Method fromPubkeyhash

lib/script/script.js:1445–1466  ·  view source on GitHub ↗

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

(hash)

Source from the content-addressed store, hash-verified

1443 */
1444
1445 fromPubkeyhash(hash) {
1446 assert(Buffer.isBuffer(hash) && hash.length === 20);
1447
1448 this.raw = Buffer.allocUnsafe(25);
1449 this.raw[0] = opcodes.OP_DUP;
1450 this.raw[1] = opcodes.OP_HASH160;
1451 this.raw[2] = 0x14;
1452 hash.copy(this.raw, 3);
1453 this.raw[23] = opcodes.OP_EQUALVERIFY;
1454 this.raw[24] = opcodes.OP_CHECKSIG;
1455
1456 hash = this.raw.slice(3, 23);
1457
1458 this.code.length = 0;
1459 this.code.push(Opcode.fromOp(opcodes.OP_DUP));
1460 this.code.push(Opcode.fromOp(opcodes.OP_HASH160));
1461 this.code.push(Opcode.fromPush(hash));
1462 this.code.push(Opcode.fromOp(opcodes.OP_EQUALVERIFY));
1463 this.code.push(Opcode.fromOp(opcodes.OP_CHECKSIG));
1464
1465 return this;
1466 }
1467
1468 /**
1469 * Create a pay-to-pubkeyhash script.

Callers 9

fromAddressMethod · 0.95
decompressScriptFunction · 0.45
verifyProgramMethod · 0.45
createCoinbaseMethod · 0.45
decompressScriptFunction · 0.45
mempool-test.jsFile · 0.45
address-test.jsFile · 0.45
randomPubkeyhashFunction · 0.45
script.jsFile · 0.45

Calls 3

fromOpMethod · 0.80
fromPushMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected