php - Bitcoin wallet address won't save -
i installing web application deals in bitcoin. got installed when open accounts page , try add bitcoin payout address keep getting "you must enter valid address" error.
the accounts section of code below payout specific part starts quater of way down, uses bitcoin_model pasted below section of code.
<?php /** * accounts.php * * provides accounts functionality, , users profiles/settings * @category accounts * @package bitwasp * @licence unlicence * @subpackage controllers * @author thomas kerin <thomas@bitwasp.co> */ defined('basepath') or exit('no direct script access allowed'); use bitwasp\bitcoinlib\bitcoinlib; /** * accounts management controller * * @category accounts * @package bitwasp * @licence unlicence * @subpackage controllers * @author thomas kerin <thomas@bitwasp.co> */ class accounts extends my_controller { /** * constructor * * @access public */ public function __construct() { parent::__construct(); $this->load->library('form_validation'); $this->load->library('gpg'); $this->load->model('accounts_model'); $this->load->model('location_model'); } /** * view users profile * uri: /user/$hash * * users can load public profile of other users. if * accounts_model\get() returns false, requested account not * exist, , user redirected homepage. otherwise, * specified view loaded layout class. * * @param string $hash */ public function view($hash) { // load specified user, redirect if don't exist. $data['user'] = $this->accounts_model->get(array('user_hash' => $hash)); if ($data['user'] == false) redirect(''); $this->load->model('items_model'); $this->load->model('review_model'); // load information view. $data['page'] = 'accounts/view'; $data['title'] = $data['user']['user_name']; $data['logged_in'] = $this->current_user->logged_in(); $data['user_role'] = $this->current_user->user_role; $data['reviews'] = $this->review_model->random_latest_reviews(8, 'user', $data['user']['user_hash']); $data['review_count']['all'] = $this->review_model->count_reviews('user', $data['user']['user_hash']); $data['review_count']['positive'] = $this->review_model->count_reviews('user', $data['user']['user_hash'], 0); $data['review_count']['disputed'] = $this->review_model->count_reviews('user', $data['user']['user_hash'], 1); $data['average_rating'] = $this->review_model->current_rating('user', $hash); if ($data['user']['user_role'] == 'vendor') $data['items'] = $this->items_model->get_list(array('vendor_hash' => $data['user']['user_hash'])); $this->_render($data['page'], $data); } /** * payout * * page allows buyers/sellers set refund/payout addresses. these addresses * destination funds meant user. administrators not have this. * * users must enter password make change. */ public function payout() { if ($this->current_user->user_role == 'admin') redirect(''); $this->load->model('bitcoin_model'); $data['address'] = $this->bitcoin_model->get_payout_address($this->current_user->user_id); if ($this->input->post('submit_payout_address') == 'submit') { if ($this->form_validation->run('submit_payout_address')) { $user_info = $this->users_model->get(array('id' => $this->current_user->user_id)); $check_login = $this->users_model->check_password($this->current_user->user_name, $this->general->password($this->input->post('password'), $user_info['salt'])); if (is_array($check_login) == true && $check_login['id'] == $this->current_user->user_id) { if ($this->bitcoin_model->set_payout_address($this->current_user->user_id, $this->input->post('address'))) { $this->current_user->set_return_message('payout address has been saved', 'success'); redirect('account'); } else { $data['returnmessage'] = 'unable update address @ time.'; } } else { $data['returnmessage'] = 'your password incorrect.'; } } } $data['page'] = 'accounts/payout'; $data['title'] = (($this->current_user->user_role == 'vendor') ? 'payout' : 'refund') . ' address'; $this->_render('accounts/payout', $data); }
below bitcoin_model section of code.
use bitwasp\bitcoinlib\bitcoinlib; use bitwasp\bitcoinlib\electrum; use bitwasp\bitcoinlib\bip32; /** * bitcoin model * * class handles database queries relating orders. * * @package bitwasp * @subpackage models * @category bitcoin * @author bitwasp * */ class bitcoin_model extends ci_model { /** * construct * * @access public * @return void */ public function __construct() { parent::__construct(); } /** * fees address * * function generates next fees address electrum * mpk, logs usage, , adds address watch address * list. * * @param string $user_hash * @param string $magic_byte * @return string */ public function get_fees_address($user_hash, $magic_byte) { $this->load->model('bip32_model'); $key = $this->bip32_model->get_next_admin_child(); $address = bitcoinlib::public_key_to_address($key['public_key'], $magic_byte); // log electrum usage $this->bitcoin_model->log_key_usage('fees', $this->bw_config->bip32_mpk, $key['key_index'], $key['public_key'], false, $user_hash); // add address watch list. $this->add_watch_address($address, 'fees'); return $address; } /** * set payout address * * @param $user_id * @param $address * @return bool */ public function set_payout_address($user_id, $address) { return $this->db->insert('payout_address', array('user_id' => $user_id, 'address' => $address, 'time' => time())) == true; } /** * payout address * * @param $user_id * @return bool */ public function get_payout_address($user_id) { $q = $this->db->limit(1)->order_by('time')->get_where('payout_address', array('user_id' => $user_id)); if ($q->num_rows() > 0) { $row = $q->row_array(); $row['time_f'] = $this->general->format_time($row['time']); } else { $row = false; } return $row; }
the bw_payout_address mysql database section.
create table if not exists `bw_payout_address` ( `id` int(9) not null, `address` varchar(40) not null, `user_id` int(9) not null, `time` int(11) not null ) engine=innodb default charset=utf8;
is there problems code or else i'm missing?
Comments
Post a Comment