|
|
@@ -81,22 +81,26 @@ class UsdtWalletService extends BaseService
|
|
|
*/
|
|
|
public function getTrxAddress()
|
|
|
{
|
|
|
- try {
|
|
|
- $headers = ["TRON-PRO-API-KEY" => $this->config['tron_api_key']];
|
|
|
- $api = new Api(new Client(['base_uri' => $this->config['tron_api_url'], $headers]));
|
|
|
+ try {
|
|
|
+ $headers = ["TRON-PRO-API-KEY" => $this->config['tron_api_key']];
|
|
|
+ $api = new Api(new Client(['base_uri' => $this->config['tron_api_url'], $headers]));
|
|
|
|
|
|
- $trxWallet = new TRX($api);
|
|
|
- $addressData = $trxWallet->generateAddress();
|
|
|
- $addressData = (array)$addressData;
|
|
|
- return ['wif' => $addressData['privateKey'], 'hexAddress' => $addressData['hexAddress'], 'address' => $addressData['address']];
|
|
|
+ $trxWallet = new TRX($api);
|
|
|
+ $addressData = $trxWallet->generateAddress();
|
|
|
+ $addressData = (array)$addressData;
|
|
|
+ return ['wif' => $addressData['privateKey'], 'hexAddress' => $addressData['hexAddress'], 'address' => $addressData['address']];
|
|
|
|
|
|
- } catch (\Exception $exception){
|
|
|
+ } catch (\Exception $exception) {
|
|
|
$url = "https://api.shasta.trongrid.io/wallet/generateaddress";
|
|
|
$data = curl_api($url);
|
|
|
- var_dump($data);
|
|
|
- //$this->error = $exception->getMessage();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ $addressData = $data ? json_decode($data, true) : [];
|
|
|
+ if ($addressData) {
|
|
|
+ return ['wif' => $addressData['privateKey'], 'hexAddress' => $addressData['hexAddress'], 'address' => $addressData['address']];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -429,7 +433,7 @@ class UsdtWalletService extends BaseService
|
|
|
'change_type' => 1,
|
|
|
'num' => $amount,
|
|
|
'total' => 0,
|
|
|
- 'balance' => floatval($balance+$amount),
|
|
|
+ 'balance' => floatval($balance + $amount),
|
|
|
'create_time' => time(),
|
|
|
'update_time' => time(),
|
|
|
'remark' => '存币',
|
|
|
@@ -463,11 +467,10 @@ class UsdtWalletService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 存币
|
|
|
- if($type == 1){
|
|
|
+ if ($type == 1) {
|
|
|
$url = sprintf($this->apiUrls['usdt_trx2_transfer_log'], $address, $limit, 'true', 'false');
|
|
|
- }
|
|
|
- // 提币
|
|
|
- else{
|
|
|
+ } // 提币
|
|
|
+ else {
|
|
|
$url = sprintf($this->apiUrls['usdt_trx2_transfer_log'], $address, $limit, 'false', 'true');
|
|
|
}
|
|
|
$headers = ["TRON-PRO-API-KEY" => $this->config['tron_api_key']];
|
|
|
@@ -481,11 +484,11 @@ class UsdtWalletService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if($datas){
|
|
|
- foreach ($datas as &$item){
|
|
|
- $time = ($item['block_timestamp']/1000);
|
|
|
- $item['time_text'] = $time? datetime($time, 'm-d H:i') : '';
|
|
|
- $item['num'] = floatval($item['value']/1000000);
|
|
|
+ if ($datas) {
|
|
|
+ foreach ($datas as &$item) {
|
|
|
+ $time = ($item['block_timestamp'] / 1000);
|
|
|
+ $item['time_text'] = $time ? datetime($time, 'm-d H:i') : '';
|
|
|
+ $item['num'] = floatval($item['value'] / 1000000);
|
|
|
$item['contact_type'] = 1;
|
|
|
$item['change_type'] = $type;
|
|
|
$item['status'] = 1;
|
|
|
@@ -548,7 +551,7 @@ class UsdtWalletService extends BaseService
|
|
|
'change_type' => 2,
|
|
|
'num' => $num,
|
|
|
'total' => 0,
|
|
|
- 'balance' => floatval($coinInfo['balance']-$num),
|
|
|
+ 'balance' => floatval($coinInfo['balance'] - $num),
|
|
|
'create_time' => time(),
|
|
|
'update_time' => time(),
|
|
|
'remark' => '提币',
|
|
|
@@ -558,7 +561,7 @@ class UsdtWalletService extends BaseService
|
|
|
|
|
|
$this->capitalModel->edit($data);
|
|
|
|
|
|
- $logs[] = ['log'=> $v,'order'=> $coinInfo];
|
|
|
+ $logs[] = ['log' => $v, 'order' => $coinInfo];
|
|
|
}
|
|
|
}
|
|
|
}
|