lib/WalletManager.php
/*
     * Get an integrated address from public keys and a payment id
     *
     * @param string A 32 byte hex encoded public spend key
     * @param string A 32 byte hex encoded public view key
     * @param string An 8 byte hex string to use as a payment id
     */
Get an integrated address from public keys and a payment id
@param string A 32 byte hex encoded public spend key
@param string A 32 byte hex encoded public view key
@param string An 8 byte hex string to use as a payment id
Get an integrated address from public keys and a payment id @param string A 32 byte hex encoded public spend key @param string A 32 byte hex encoded public view key @param string An 8 byte hex string to use as a payment id
public function integrated_encode($public_spendkey, $public_viewkey, $payment_id = null)
    {
        if (empty($payment_id)) {
            $payment_id = $this->generate_payment_id($this->payment_id_length_integrated);
        }
        if (strlen($public_spendkey) !== 64) {
            throw new Exception('Error: Invalid public spend key length');
        }
        if (strlen($public_viewkey) !== 64) {
            throw new Exception('Error: Invalid public view key length');
        }
        if (strlen($payment_id) !== $this->payment_id_length_integrated) {
            throw new Exception('Error: Invalid payment id length');
        }
        $data = $this->wallet_integrated_prefix . $public_spendkey . $public_viewkey . $payment_id;
        $checksum = substr($this->keccak_256($data), 0, 8);
        $iAddress = $this->base58->encode($data.$checksum);
        $address = $this->encode_address($public_spendkey, $public_viewkey);
        return array(
            'integrated_address' => $iAddress,
            'address' => $address,
            'view_public' => $public_viewkey,
            'spend_public' => $public_spendkey,
            'payment_id' => $payment_id,
        );
    }
public function integrated_encode ( $ public_spendkey , $ public_viewkey , $ payment_id = null ) { if ( empty ( $ payment_id ) ) { $ payment_id = $ this -> generate_payment_id ( $ this -> payment_id_length_integrated ) ; } if ( strlen ( $ public_spendkey ) !== 64 ) { throw new Exception ( 'Error: Invalid public spend key length' ) ; } if ( strlen ( $ public_viewkey ) !== 64 ) { throw new Exception ( 'Error: Invalid public view key length' ) ; } if ( strlen ( $ payment_id ) !== $ this -> payment_id_length_integrated ) { throw new Exception ( 'Error: Invalid payment id length' ) ; } $ data = $ this -> wallet_integrated_prefix . $ public_spendkey . $ public_viewkey . $ payment_id ; $ checksum = substr ( $ this -> keccak_256 ( $ data ) , 0 , 8 ) ; $ iAddress = $ this -> base58 -> encode ( $ data . $ checksum ) ; $ address = $ this -> encode_address ( $ public_spendkey , $ public_viewkey ) ; return array ( 'integrated_address' => $ iAddress , 'address' => $ address , 'view_public' => $ public_viewkey , 'spend_public' => $ public_spendkey , 'payment_id' => $ payment_id , ) ; }
Get an integrated address from public keys and a payment id
 @param string A 32 byte hex encoded public spend key
 @param string A 32 byte hex encoded public view key
 @param string An 8 byte hex string to use as a payment id
Get an integrated address from public keys and a payment id @param string A 32 byte hex encoded public spend key @param string A 32 byte hex encoded public view key @param string An 8 byte hex string to use as a payment id
// Generate payment id if required. // Validate public spend key length. // Validate public view key length. // Validate payment id length. // 0x13 is the mainnet network byte for integrated addresses