lib/transaction.js
function mkPubkeyHashReplayScript(address, blockHeight, blockHash) {
  var pubKeyHash = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : zconfig.mainnet.pubKeyHash;

  // Get lengh of pubKeyHash (so we know where to substr later on)
  var addrHex = bs58check.decode(address).toString('hex');

  // Cut out pubKeyHash
  var subAddrHex = addrHex.substring(pubKeyHash.length, addrHex.length);

  // Minimal encoding
  var blockHeightBuffer = Buffer.alloc(4);
  blockHeightBuffer.writeUInt32LE(blockHeight, 0);
  if (blockHeightBuffer[3] === 0x00) {
    blockHeightBuffer = blockHeightBuffer.slice(0, 3);
  }
  var blockHeightHex = blockHeightBuffer.toString('hex');

  // block hash is encoded in little indian
  var blockHashHex = Buffer.from(blockHash, 'hex').reverse().toString('hex');

  // '14' is the length of the subAddrHex (in bytes)
  return zopcodes.OP_DUP + zopcodes.OP_HASH160 + zbufferutils.getPushDataLength(subAddrHex) + subAddrHex + zopcodes.OP_EQUALVERIFY + zopcodes.OP_CHECKSIG + zbufferutils.getPushDataLength(blockHashHex) + blockHashHex + zbufferutils.getPushDataLength(blockHeightHex) + blockHeightHex + zopcodes.OP_CHECKBLOCKATHEIGHT;
}
function mkPubkeyHashReplayScript(address, blockHeight, blockHash) {
  var pubKeyHash = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : zconfig.mainnet.pubKeyHash;

  // Get lengh of pubKeyHash (so we know where to substr later on)
  var addrHex = bs58check.decode(address).toString('hex');

  // Cut out pubKeyHash
  var subAddrHex = addrHex.substring(pubKeyHash.length, addrHex.length);

  // Minimal encoding
  var blockHeightBuffer = Buffer.alloc(4);
  blockHeightBuffer.writeUInt32LE(blockHeight, 0);
  if (blockHeightBuffer[3] === 0x00) {
    blockHeightBuffer = blockHeightBuffer.slice(0, 3);
  }
  var blockHeightHex = blockHeightBuffer.toString('hex');

  // block hash is encoded in little indian
  var blockHashHex = Buffer.from(blockHash, 'hex').reverse().toString('hex');

  // '14' is the length of the subAddrHex (in bytes)
  return zopcodes.OP_DUP + zopcodes.OP_HASH160 + zbufferutils.getPushDataLength(subAddrHex) + subAddrHex + zopcodes.OP_EQUALVERIFY + zopcodes.OP_CHECKSIG + zbufferutils.getPushDataLength(blockHashHex) + blockHashHex + zbufferutils.getPushDataLength(blockHeightHex) + blockHeightHex + zopcodes.OP_CHECKBLOCKATHEIGHT;
}
function mkPubkeyHashReplayScript ( address , blockHeight , blockHash ) { var pubKeyHash = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : zconfig . mainnet . pubKeyHash ; // Get lengh of pubKeyHash (so we know where to substr later on) var addrHex = bs58check . decode ( address ) . toString ( 'hex' ) ; // Cut out pubKeyHash var subAddrHex = addrHex . substring ( pubKeyHash . length , addrHex . length ) ; // Minimal encoding var blockHeightBuffer = Buffer . alloc ( 4 ) ; blockHeightBuffer . writeUInt32LE ( blockHeight , 0 ) ; if ( blockHeightBuffer [ 3 ] === 0x00 ) { blockHeightBuffer = blockHeightBuffer . slice ( 0 , 3 ) ; } var blockHeightHex = blockHeightBuffer . toString ( 'hex' ) ; // block hash is encoded in little indian var blockHashHex = Buffer . from ( blockHash , 'hex' ) . reverse ( ) . toString ( 'hex' ) ; // '14' is the length of the subAddrHex (in bytes) return zopcodes . OP_DUP + zopcodes . OP_HASH160 + zbufferutils . getPushDataLength ( subAddrHex ) + subAddrHex + zopcodes . OP_EQUALVERIFY + zopcodes . OP_CHECKSIG + zbufferutils . getPushDataLength ( blockHashHex ) + blockHashHex + zbufferutils . getPushDataLength ( blockHeightHex ) + blockHeightHex + zopcodes . OP_CHECKBLOCKATHEIGHT ; }
/* More info: https://github.com/ZencashOfficial/zen/blob/master/src/script/standard.cpp#L377
Given an address, generates a pubkeyhash replay type script needed for the transaction
@param {String} address
@param {Number} blockHeight
@param {Number} blockHash
@param {String} pubKeyHash (optional)
return {String} pubKeyScript
/ * More info : https : // github . com / ZencashOfficial / zen / blob / master / src / script / standard . cpp#L377 Given an address generates a pubkeyhash replay type script needed for the transaction