Example #1
0
 function getJSON($arguments)
 {
     $result = array();
     foreach (get_all_currencies() as $cur) {
         $instance = \DiscoveredComponents\Currencies::getInstance($cur);
         $result[] = array("code" => $instance->getCode(), "abbr" => $instance->getAbbr(), "name" => $instance->getName(), "cryptocurrency" => $instance->isCryptocurrency(), "fiat" => $instance->isFiat(), "commodity" => $instance->isCommodity());
     }
     return $result;
 }
Example #2
0
/**
 * Return a HTML link for inspecting a given cryptocurrency address.
 */
function crypto_address($currency, $address)
{
    foreach (\DiscoveredComponents\Currencies::getAddressCurrencies() as $cur) {
        if ($cur === $currency) {
            $instance = \DiscoveredComponents\Currencies::getInstance($cur);
            return "<span class=\"address " . $currency . "_address\"><code>" . htmlspecialchars($address) . "</code>\n        <a class=\"inspect\" href=\"" . htmlspecialchars($instance->getBalanceURL($address)) . "\" title=\"Inspect with " . htmlspecialchars($instance->getExplorerName()) . "\">?</a>\n      </span>";
        }
    }
    foreach (get_blockchain_currencies() as $explorer => $currencies) {
        foreach ($currencies as $cur) {
            if ($cur == $currency) {
                return "<span class=\"address " . $currency . "_address\"><code>" . htmlspecialchars($address) . "</code>\n          <a class=\"inspect\" href=\"" . htmlspecialchars(sprintf(get_site_config($currency . "_address_url"), $address)) . "\" title=\"Inspect with " . htmlspecialchars($explorer) . "\">?</a>\n        </span>";
            }
        }
    }
    return htmlspecialchars($address);
}
Example #3
0
 function getJSON($arguments)
 {
     $instance = \DiscoveredComponents\Currencies::getInstance($arguments['currency']);
     return array("code" => $instance->getCode(), "abbr" => $instance->getAbbr(), "name" => $instance->getName(), "cryptocurrency" => $instance->isCryptocurrency(), "fiat" => $instance->isFiat(), "commodity" => $instance->isCommodity());
 }
Example #4
0
/**
 * Address job for a currency that has been discovered through
 * DiscoveredComponents\Currencies.
 */
if (!$currency) {
    throw new JobException("No currency defined");
}
// get the relevant address
$q = db()->prepare("SELECT * FROM addresses WHERE user_id=? AND id=?");
$q->execute(array($job['user_id'], $job['arg_id']));
$address = $q->fetch();
if (!$address) {
    throw new JobException("Cannot find an address " . $job['arg_id'] . " for user " . $job['user_id']);
}
$instance = \DiscoveredComponents\Currencies::getInstance($currency);
if ($instance instanceof \Openclerk\Currencies\ConfirmableCurrency) {
    // directly request confirmations
    $balance = $instance->getBalanceWithConfirmations($address['address'], \Openclerk\Config::get($currency . "_confirmations", 6), $logger);
    insert_new_address_balance($job, $address, $balance);
} else {
    if ($instance instanceof \Openclerk\Currencies\BlockBalanceableCurrency) {
        // get the most recent block count, to calculate confirmations
        $block = null;
        $q = db()->prepare("SELECT * FROM blockcount_" . $currency . " WHERE is_recent=1");
        $q->execute();
        if ($result = $q->fetch()) {
            $block = $result['blockcount'] - \Openclerk\Config::get($currency . "_confirmations", 6);
        }
        $balance = $instance->getBalanceAtBlock($address['address'], $block, $logger);
        insert_new_address_balance($job, $address, $balance);
Example #5
0
function get_explorer_address($currency, $address)
{
    foreach (\DiscoveredComponents\Currencies::getAddressCurrencies() as $cur) {
        if ($cur === $currency) {
            $instance = \DiscoveredComponents\Currencies::getInstance($cur);
            return $instance->getBalanceURL($address);
        }
    }
    foreach (get_blockchain_currencies() as $explorer => $currencies) {
        foreach ($currencies as $cur) {
            if ($cur == $currency) {
                return sprintf(get_site_config($currency . "_address_url"), $address);
            }
        }
    }
}
<p>
  <?php 
echo htmlspecialchars(get_site_config('site_name'));
?>
 currently supports the following cryptocurrencies:
</p>

<p>
  <ul class="currency_list">
    <?php 
// get_all_cryptocurrencies() so that it's sorted
foreach (get_all_cryptocurrencies() as $code) {
    if (!\DiscoveredComponents\Currencies::hasKey($code)) {
        continue;
    }
    $currency = \DiscoveredComponents\Currencies::getInstance($code);
    echo "<li>";
    echo "<span class=\"currency_name_" . $currency->getCode() . "\">" . link_to($currency->getURL(), $currency->getName(), array("target" => "_blank")) . "</span>";
    foreach ($currency->getCommunityLinks() as $url => $title) {
        echo " - " . link_to($url, $title, array("target" => "_blank"));
    }
    echo "</li>";
}
?>
  </ul>
</p>

<p>
  Support for additional cryptocurrencies will be <a href="<?php 
echo htmlspecialchars(url_for('help/add_currency'));
?>