Esempio n. 1
0
 public function withdraw($user_id, $wallet_id, $address, $total, $fee_withdraw)
 {
     $address = mysql_real_escape_string($address);
     $total = mysql_real_escape_string($total);
     $user_id = mysql_real_escape_string($user_id);
     $wallet_id = mysql_real_escape_string($wallet_id);
     $fee = $this->getTxFee();
     $fee_amount = $fee_withdraw + $fee;
     $receive_amount = $total - $fee_amount;
     Withdraw::insert(array('user_id' => $user_id, 'wallet_id' => $wallet_id, 'to_address' => $address, 'amount' => $total, 'fee_amount' => $fee_amount, 'receive_amount' => $receive_amount, 'created_at' => date('Y-m-d H:i:s')));
     return $this->jsonRPCclient->sendtoaddress($address, (double) sprintf("%.8f", $total - $fee));
     //Return transaction id if success
 }
Esempio n. 2
0
 public function doWithdraw_bakup()
 {
     $amount = Input::get('amount');
     $address = Input::get('address');
     $wallet_id = Input::get('wallet_id');
     $password = Input::get('password');
     $wallet = Wallet::find($wallet_id);
     $setting = new Setting();
     if ($setting->getSetting('disable_withdraw', 0)) {
         return Redirect::to('user/withdraw/' . $wallet->id)->with('notice', 'Sorry. we pause function withdrawals');
         //"Not connect to this wallet."
     }
     $user = User::find((int) Confide::user()->id);
     $balance = new Balance();
     if (Hash::check($password, Confide::user()->password)) {
         $balance_amount = $balance->getBalance($wallet->id);
         $fee_withdraw = new FeeWithdraw();
         $fee = $fee_withdraw->getFeeWithdraw($wallet->id);
         $net_total = $amount - $fee;
         $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
         $min_amount = $wallet->getTxFee() + $fee;
         //$wallet->getTxFee();
         if ($amount < $min_amount) {
             return Redirect::to('user/withdraw/' . $wallet->id)->with('error', "Amount withdraw must be equal to or great than " . $min_amount . ".");
         } elseif ($balance_amount >= $net_total) {
             try {
                 //$wallet->connectJsonRPCclient($wallet->wallet_username,$wallet->wallet_password,$wallet->wallet_ip,$wallet->port);
                 $txid = $wallet->sendToAddress($address, $net_total);
                 if ($txid) {
                     $balance->takeMoney($amount, $wallet->id, $user->id);
                     Withdraw::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'to_address' => $address, 'amount' => $amount, 'fee_amount' => $fee, 'receive_amount' => $net_total, 'created_at' => date('Y-m-d H:i:s'), 'status' => 1, 'transaction_id' => $txid));
                     return Redirect::to('user/withdraw/' . $wallet->id)->with('notice', "You withdrawed " . sprintf('%.8f', $net_total) . " " . $wallet->type . " to address: " . $address . ".");
                 } else {
                     return Redirect::to('user/withdraw/' . $wallet->id)->with('notice', "Can not " . $wallet->type . ".");
                 }
             } catch (Exception $e) {
                 return Redirect::to('user/withdraw/' . $wallet->id)->with('notice', Lang::get('texts.not_connect_wallet'));
                 //'Caught exception: '.$e->getMessage()
             }
         } else {
             return Redirect::to('user/withdraw/' . $wallet->id)->with('error', "Your balance are not enough.");
         }
     } else {
         return Redirect::to('user/withdraw/' . $wallet->id)->with('error', "Password invalid.");
     }
 }
 public function doSendCoin()
 {
     $amount = Input::get('amount');
     $address = Input::get('address');
     $wallet_type = Input::get('wallet_type');
     $wallet = Wallet::where('type', $wallet_type)->first();
     //echo "<pre>wallet: "; print_r($wallet->toArray()); echo "</pre>";
     $user = Confide::user();
     if ($user->hasRole('Admin')) {
         try {
             $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port);
             $txid = $wallet->sendToAddress($address, $amount);
             $fee = $wallet->getTxFee();
             $net_total = $amount - $fee;
             if ($txid) {
                 Withdraw::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'to_address' => $address, 'amount' => $amount, 'fee_amount' => $fee, 'receive_amount' => $net_total, 'created_at' => date('Y-m-d H:i:s'), 'status' => 1, 'transaction_id' => $txid));
                 return Redirect::to('admin/manage/funds')->with('success', Lang::get('admin_messages.withdraw_success', array('amount' => sprintf('%.8f', $net_total), 'coin' => $wallet->type, 'address' => $address, 'fee' => $fee)));
             } else {
                 return Redirect::to('admin/manage/funds')->with('notice', Lang::get('admin_messages.cannot_send_coin', array('name' => $wallet->name)));
             }
         } catch (Exception $e) {
             return Redirect::to('admin/manage/funds')->with('notice', Lang::get('admin_messages.cannot_connect_wallet', array('name' => $wallet->name)));
             //'Caught exception: '.$e->getMessage()
         }
     }
 }