public function generateNewAddrDeposit() { if (!Confide::user()) { return View::make(Config::get('confide::login_form')); } $user = Confide::user(); $user_id = $user->id; $wallet_id = $_POST['wallet_id']; $wallet = Wallet::find($wallet_id); $deposit = new Deposit(); $user_address_deposit = new UserAddressDeposit(); $addr_deposit = UserAddressDeposit::where('wallet_id', $wallet->id)->where('user_id', $user_id)->first(); if (isset($addr_deposit->addr_deposit) && $deposit->addressIsDesposited($addr_deposit->addr_deposit)) { $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); $new_addr_deposit = $wallet->getNewDepositReceiveAddress($user->username); $user_address_deposit->updateAddress($user_id, $wallet->id, $new_addr_deposit); echo json_encode(array('status' => 'success', 'address' => $new_addr_deposit)); exit; } else { echo json_encode(array('status' => 'error', 'message' => 'You cannot generate a new address, without using the old')); exit; } }
public function getWalletById($walletId) { $walletModel = new Wallet(); $return_wallet = $walletModel->find('all', array('conditions' => array('Wallet.id' => $walletId))); return $return_wallet; }
public function doTransfer() { $trade_key = Input::get('trade_key'); $amount = Input::get('amount'); $wallet_id = Input::get('wallet_id'); $password = Input::get('password'); $wallet = Wallet::find($wallet_id); $balance = new Balance(); $user = Confide::user(); if (Hash::check($password, $user->password)) { $user_receive = User::where('trade_key', $trade_key)->first(); $amount_balance = $balance->getBalance($wallet->id); if (!isset($user_receive->username)) { return Redirect::to('user/transfer-coin/' . $wallet->id)->with('error', 'Sorry. The trade key not exist!'); } elseif ($user_receive->id == $user->id) { return Redirect::to('user/transfer-coin/' . $wallet->id)->with('error', 'Sorry. You can not referrer to yourself!'); } elseif ($amount_balance < $amount) { return Redirect::to('user/transfer-coin/' . $wallet->id)->with('error', 'Amount should be less than or equal to your balance.'); } else { if ($balance->takeMoney($amount, $wallet->id, $user->id)) { $balance->addMoney($amount, $wallet->id, $user_receive->id); $transfer_his = new Transfer(); $transfer_his->sender = $user->id; $transfer_his->receiver = $user_receive->id; $transfer_his->wallet_id = $wallet->id; $transfer_his->amount = $amount; $transfer_his->save(); return Redirect::to('user/transfer-coin/' . $wallet->id)->with('success', 'You sent to user "' . $user_receive->username . '" ' . $amount . ' ' . $wallet->getType($wallet->id) . '.'); } } } else { return Redirect::to('user/transfer-coin/' . $wallet->id)->with('error', "Password invalid."); } }
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); } } }