Exemplo n.º 1
0
 public function CreateWallet()
 {
     $wallet = Coin::BaseWallet();
     if (strtolower(Input::get('coin')) == 'btc') {
         $wallet = Bitcoin::CreateWallet();
     } elseif (strtolower(Input::get('coin')) == 'aur') {
         $wallet['CoinCode'] = 'aur';
         $wallet['Reply'] = 'Failure';
         $wallet['Err'] = 'Not Implemented Yet';
     }
     return $wallet;
 }
Exemplo n.º 2
0
 public static function CreateWallet()
 {
     $fields = ['password' => urlencode(Auth::user()->btc_wallet_password), 'api_code' => urlencode(Settings::Value('blockchain_info_api_code')), 'label' => urlencode(Auth::user()->username . " at Otoru Dice"), 'email' => urlencode(Auth::user()->email)];
     //url-ify the data for the POST
     $fields_string = '';
     foreach ($fields as $key => $value) {
         $fields_string .= $key . '=' . $value . '&';
     }
     rtrim($fields_string, '&');
     //open connection
     $ch = curl_init();
     //set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, 'https://blockchain.info/api/v2/create_wallet');
     curl_setopt($ch, CURLOPT_VERBOSE, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
     //execute post
     $raw = curl_exec($ch);
     $result = json_decode($raw, true);
     $wallet = Coin::BaseWallet();
     $wallet['CoinCode'] = 'btc';
     $wallet['guid'] = $result['guid'];
     $wallet['address'] = $result['address'];
     if ($result) {
         $user = User::find(Auth::user()->id);
         $user->btc_wallet_guid = $result['guid'];
         $user->btc_wallet_address = $result['address'];
         $user->save();
         $wallet['Reply'] = 'Success';
     } else {
         $wallet['Reply'] = 'Failure';
         $wallet['Err'] = $raw;
     }
     return $wallet;
 }