nl_tokens: / * 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
pl_tokens: 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 = <mask> . 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 ; }