Example #1
0
 public function add_address($wallet_id, $address, $userid = 0, $is_change_address = 0, $address_num = 0, $key_id = 0)
 {
     // Initialize
     global $config;
     // Add address to db
     DB::insert('coin_addresses', array('wallet_id' => $wallet_id, 'key_id' => $key_id, 'userid' => $userid, 'is_change_address' => $is_change_address, 'address_num' => $address_num, 'address' => $address));
     // Init RPC client
     include_once SITE_PATH . '/data/lib/jsonRPCClient.php';
     $rpc_url = 'http://' . $config['btc_rpc_user'] . ':' . $config['btc_rpc_pass'] . '@' . $config['btc_rpc_host'] . ':' . $config['btc_rpc_port'];
     $client = new jsonRPCClient($rpc_url);
     // Import address to bitcoind
     try {
         $client->importaddress($address, "", false);
     } catch (Exception $e) {
         trigger_error("Unable to import address into Bitcoin Core as a watch only address, {$address}.  Please ensure Bitcoin Core is running, and in the correct mode (mainnet / testnet).", E_USER_ERROR);
     }
 }