public function formDeposit($wallet_id = '') { $user = Confide::user(); $user_id = $user->id; $data = array(); if ($wallet_id == '') { $wallet = Wallet::first(); } else { $wallet = Wallet::find($wallet_id); } $balance = new Balance(); $order = new Order(); $market = new Market(); $data['page'] = 'deposit'; $data['current_coin'] = $wallet->type; //$wallet->getType($wallet_id); $data['name_coin'] = $wallet->name; $balance_amount = $balance->getBalance($wallet_id); $data['balance'] = sprintf('%.8f', $balance_amount); if ($wallet->is_moneypaper) { $data['method_deposits'] = MethodDepositCurrency::orderBy('dname')->get(); } elseif ($wallet->enable_deposit) { //echo "<pre>".dd(DB::getQueryLog())."</pre>"; $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); //echo "Fee: ".$wallet->getTxFee(); //echo "<br>getDepositAddress: ".$wallet->getDepositAddress('test'); // echo "<br>getReceivedByAccount: ".$wallet->getReceivedByAccount(''); $addr_deposit = UserAddressDeposit::where('wallet_id', $wallet->id)->where('user_id', $user->id)->first(); $address = ''; if (!isset($addr_deposit->addr_deposit)) { try { $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); $address = $wallet->getNewDepositReceiveAddress($user->username); UserAddressDeposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'addr_deposit' => $address)); } catch (Exception $e) { $data['error_message'] = Lang::get('texts.not_connect_wallet'); //'Caught exception: '.$e->getMessage()."\n"; // } } else { $address = $addr_deposit->addr_deposit; } $data['address_deposit'] = $address; } $data['wallet_id'] = $wallet->id; $data['wallet'] = $wallet; return View::make('user.profile', $data); }
public function updateAddress($user_id, $wallet_id, $address) { $useraddress = UserAddressDeposit::where('user_id', $user_id)->where('wallet_id', $wallet_id)->first(); if (isset($useraddress->addr_deposit)) { UserAddressDeposit::where('id', $useraddress->id)->update(array('addr_deposit' => $address)); } else { UserAddressDeposit::insert(array('user_id' => $user_id, 'wallet_id' => $wallet_id, 'addr_deposit' => $address)); } }
public function blocknotifyUpdateDeposit_bakup($wallet_type = '') { $blockhash = isset($_GET['trxhash']) ? $_GET['trxhash'] : 0; Log::info("*******Blocknotify Update Deposit: " . $blockhash . " -- wallet_type: " . $wallet_type); $wallet = Wallet::where('type', strtoupper($wallet_type))->first(); if ($blockhash != 0 && $wallet_type != '') { $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); //update the pendding deposits from database $this->updateDataDeposit($wallet); //$listtrans = $wallet->getListTransactions(); //echo "<pre>listtrans: "; print_r($listtrans); echo "</pre>"; @Log::info("\n" . "List transaction: ", $listtrans); //get info of block to find transaction of this system $results = $wallet->getBlock($blockhash); if (isset($results['confirmations'])) { @Log::info("\n" . 'Result Blocknotify: ', $results); $txids = $results['tx']; $balance = new Balance(); foreach ($txids as $transaction_id) { try { $trans = $wallet->getTransaction($transaction_id); if ($trans != null) { $account = $trans["details"][0]["account"]; $category = $trans["details"][0]["category"]; $confirms = $trans["confirmations"]; //send,receive $address_ = $trans["details"][0]["address"]; $amount = $trans["amount"]; Log::info("\n" . "transaction: ", $trans); Log::info("\n" . "------Account: " . $account . " -- category:" . $category . " --address: " . $address_); //mail("*****@*****.**", 'Deposit Cron: ', var_export($trans, true)); $deposit = Deposit::where('transaction_id', $transaction_id)->first(); $user = User::where('username', $account)->first(); if (!isset($deposit->id)) { if ($category == "receive" && isset($user->id)) { //check this transaction is of this system $deposit_address = Deposit::where('wallet_id', $wallet->id)->where('user_id', $user->id)->where('address', $address_)->first(); $addr_deposit = UserAddressDeposit::where('wallet_id', $wallet->id)->where('user_id', $user->id)->where('addr_deposit', $address_)->first(); if (isset($deposit_address->address) || isset($addr_deposit->addr_deposit)) { if ($confirms >= 3) { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 1, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); $balance->addMoney($amount, $wallet->id, $user->id); Log::info("\n" . $amount . " " . $wallet->type . " was credited to your account"); } else { Deposit::insert(array('user_id' => $user->id, 'wallet_id' => $wallet->id, 'transaction_id' => $transaction_id, 'amount' => $amount, 'paid' => 0, 'confirmations' => $confirms, 'address' => $address_, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'))); Log::info("\n" . "This Deposit is unconfirmed. Current confirmations:" . $confirms . ". Required : 3."); } } } else { Log::info("\n" . "transaction is not a deposit or account is invalid."); } } else { Deposit::where('id', $deposit->id)->update(array('confirmations' => $confirms)); } } else { Log::info("\n" . "We can't find any information about this deposit. contact support."); } //trans } catch (Exception $e) { Log::info('Caught exception: ' . $e->getMessage() . "\n"); } } } } else { Log::info('------------------- Error: not param blockhash or wallet_type from _GET'); } Log::info("*******Stop Blocknotify Update Deposit*************"); }
public function deleteWallet() { $wallet_id = Input::get('wallet_id'); $wallet = Wallet::find($wallet_id); if (isset($wallet->id)) { $markets = Market::where("wallet_from", $wallet_id)->orwhere("wallet_to", $wallet_id)->get(); $arr_markets = array(0); foreach ($markets as $market) { $arr_markets[] = $market->id; } FeeWithdraw::where("wallet_id", $wallet_id)->delete(); WalletLimitTrade::where("wallet_id", $wallet_id)->delete(); UserAddressDeposit::where("wallet_id", $wallet_id)->delete(); Balance::where("wallet_id", $wallet_id)->delete(); Transfer::where("wallet_id", $wallet_id)->delete(); Deposit::where("wallet_id", $wallet_id)->delete(); Withdraw::where("wallet_id", $wallet_id)->delete(); Order::whereIn('market_id', $arr_markets)->delete(); Trade::whereIn('market_id', $arr_markets)->delete(); FeeTrade::whereIn('market_id', $arr_markets)->delete(); Market::where("wallet_from", $wallet_id)->orwhere("wallet_to", $wallet_id)->delete(); Wallet::where('id', $wallet_id)->delete(); $message = $wallet->type . " " . Lang::get('admin_messages.delete_success'); if (Input::get('isAjax')) { echo json_encode(array('status' => 'success', 'message' => $message)); exit; } else { return Redirect::to('admin/manage/wallets')->with('success', $message); } } else { $message = Lang::get('admin_messages.wallet_not_exist'); if (Input::get('isAjax')) { echo json_encode(array('status' => 'error', 'message' => $message)); exit; } else { return Redirect::to('admin/manage/wallets')->with('error', $message); } } }