Finally figured out why I get devided by zero errors: the MTgox address has a "data" prefix now.

I don't have enough knowledge to fix the code and write a patch, but this is what I figured out so far: The adress in line 371 in uc_bitcoin.module should be https://data.mtgox.com/api/1/BTC' . $order->currency . '/ticker'. Furthermore, there should be some code added to handle situations where the response code is not successful=200. For example handling code -110 which is returned if the MTgox address is wrong.

function uc_bitcoin_exchange_rate($order) {
  ...cut away some code...
  if (in_array($order->currency, $mtGox_currencies)) { //line 371 of uc_bitcoin.module
    if ($response = drupal_http_request('https://data.mtgox.com/api/1/BTC' . $order->currency . '/ticker')) {
      if ($response->code == 200) { 
        $data = json_decode($response->data);
        $rate = $data->return->avg->value;
      }
    } //missing code for response code that are not 200, like -110
  }

Maybe someone with more knowledge could write a patch and update the module?

For those who want to just use uc_bitcoin and are getting a devided by zero error: go to the uc_bitcoin module on your server. Open uc_bitcoin.module, look for line 371 and add "data." to the mtgox address used to lookup the latest exchange rate.

Comments

drsnuggles’s picture

Issue summary: View changes

update

drsnuggles’s picture

Issue summary: View changes

update

dgtlmoon’s picture

Status: Needs work » Fixed

Damn how annoying, and right now data.mtgox.com is a wildcard hostname.

Anyway, committed a fix (2d39436) and made the error checking a little more heavy duty, thanks!

dgtlmoon’s picture

Version: 7.x-1.31 » 7.x-1.x-dev

fixed in latest dev, queued in 7.x-1.32 release

drsnuggles’s picture

Thanks for the fix!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

update