<?php

class general
{
    public $mainWalletAddress = 'TS6XzmBhNHkhhnWAvi5JbUhFjPHss41N2d'; 


    function checkTransactionStatus($transactionHash, $price, $db)
    {

        if ($db->checkHash($transactionHash) != 'ok') {
            return 'no';
        }


        $ch = curl_init("https://apilist.tronscan.org/api/transaction-info?hash=$transactionHash");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // curl_setopt($ch, CURLOPT_POST, 1);
        $result = curl_exec($ch);
        print('result ' . $result);
        $data = json_decode($result, true);
        print("<hr /><hr /><hr />");

        print_r($data);

        print("<hr /><hr /><hr />");

        print_r($data['tokenTransferInfo']);


        $actualPrice = $data['tokenTransferInfo']['amount_str'] / pow(10, $data['tokenTransferInfo']['decimals']);



        if ($data['tokenTransferInfo']['symbol'] == 'USDT' && $data['tokenTransferInfo']['to_address'] == $this->mainWalletAddress && $actualPrice == $price) {
            return 'ok';
        } else {
            return 'no';
        }

    }

}

?>