* Inject properties from a pay-to-pubkeyhash script. * @private * @param {Buffer} hash
(hash)
| 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. |
no test coverage detected