|
|
@@ -120,10 +120,14 @@ class Ledger extends Api
|
|
|
{
|
|
|
$amount = $this->request->post('amount'); // 茶宝
|
|
|
$account= $this->request->post('account', ''); // 账号
|
|
|
- $type = (strlen($account) > 11)? 0: 1; // type: 0地址 1uid
|
|
|
+ $type = (substr($account, 0, 2) == '0x')? 0: 1; // type: 0地址 1uid
|
|
|
if(empty($amount) || empty($account)){
|
|
|
$this->error(__('Parameter error'));
|
|
|
}
|
|
|
+ // 验证地址是否以0x开头
|
|
|
+ if($type == 0 && substr($account, 0, 2) !== '0x'){
|
|
|
+ $this->error(__('Invalid address format, must start with 0x'));
|
|
|
+ }
|
|
|
$real = bcsub($amount, bcmul(getConfig('frozen_transfer'), $amount, 2), 2) ; // 手续费
|
|
|
// 启动事务
|
|
|
Db::startTrans();
|
|
|
@@ -164,17 +168,21 @@ class Ledger extends Api
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 茶宝赠送
|
|
|
+ * 茶宝赠送 0x
|
|
|
* @return void
|
|
|
*/
|
|
|
public function chabaoGift(UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
|
|
|
{
|
|
|
$amount = $this->request->post('amount'); // 茶宝
|
|
|
$account= $this->request->post('account', ''); // 账号
|
|
|
- $type = (strlen($account) > 11)? 0: 1; // type: 0地址 1uid
|
|
|
+ $type = (substr($account, 0, 2) == '0x')? 0: 1; // type: 0地址 1uid
|
|
|
if(empty($amount) || empty($account)){
|
|
|
$this->error(__('Parameter error'));
|
|
|
}
|
|
|
+ // 验证地址是否以0x开头
|
|
|
+ if($type == 0 && substr($account, 0, 2) !== '0x'){
|
|
|
+ $this->error(__('Invalid address format, must start with 0x'));
|
|
|
+ }
|
|
|
$real = bcsub($amount, bcmul(getConfig('chabao_giveaway'), $amount, 2), 2) ; // 手续费
|
|
|
|
|
|
// 启动事务
|
|
|
@@ -253,4 +261,4 @@ class Ledger extends Api
|
|
|
{
|
|
|
return $this->success('', ['value'=> Env::get('rental.pay_address'), 'name'=>getConfig('recharge_txt')]);
|
|
|
}
|
|
|
-}
|
|
|
+}
|