function bitcoin_link($params) { # Gateway Specific Variables $u = $params['username']; $p = $params['password']; $h = $params['host'] . ':' . $params['port']; $rpc = 'http://' . $u . ':' . $p . '@' . $h; # Invoice Variables $invoiceid = $params['invoiceid']; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code # Client Variables $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; # Build Bitcoin Information Here require_once 'bitcoin/jsonRPCClient.php'; $bitcoin = new jsonRPCClient($rpc); if (!$bitcoin->getinfo()) { die('could not connect to bitcoind'); } $address = $bitcoin->getaccountaddress($params['clientdetails']['userid'] . '-' . $invoiceid); # Enter your code submit to the gateway... $code = 'Send Payments to: ' . $address . ''; return $code; }
public function confirm_sent() { $this->load->model('checkout/order'); $order_id = $this->session->data['order_id']; $order = $this->model_checkout_order->getOrder($order_id); $current_default_currency = $this->config->get('config_currency'); $eMark_DEM_decimal = $this->config->get('eMark_DEM_decimal'); $eMark_total = $order['eMark_total']; $eMark_address = $order['eMark_address']; require_once 'jsonRPCClient.php'; $eMark = new jsonRPCClient('http://' . $this->config->get('eMark_rpc_username') . ':' . $this->config->get('eMark_rpc_password') . '@' . $this->config->get('eMark_rpc_address') . ':' . $this->config->get('eMark_rpc_port') . '/'); try { $eMark_info = $eMark->getinfo(); } catch (Exception $e) { $this->data['error'] = true; } try { $received_amount = $eMark->getreceivedbyaddress($eMark_address, 0); if (round((double) $received_amount, $eMark_DEM_decimal) >= round((double) $eMark_total, $eMark_DEM_decimal)) { $order = $this->model_checkout_order->getOrder($order_id); $this->model_checkout_order->confirm($order_id, $this->config->get('eMark_order_status_id')); echo "1"; } else { echo "0"; } } catch (Exception $e) { $this->data['error'] = true; echo "0"; } }
/** * Test if the connection to the Bitcoin JSON-RPC server is working * * The check is done by calling the server's getinfo() method and checking * for a fault. * * @return mixed boolean TRUE if successful, or a fault string otherwise * @access public * @throws none */ public function can_connect() { try { $r = parent::getinfo(); } catch (Exception $e) { return $e->getMessage(); } return true; }
function funct_Billing_JSONRPC_GetInfo($strConnectionString) { //works //get info about wallet as | delimited string if (!$strConnectionString) { $strConnectionString = JSONRPC_CONNECTIONSTRING; } //echo "conn = $strConnectionString <br>"; $mybtc = new jsonRPCClient($strConnectionString); $strReturnInfo = $mybtc->getinfo(); //echo "array=$strReturnInfo<br>"; foreach ($strReturnInfo as $key => $value) { //echo $key."=".$value."<br>"; $strReturn = $strReturn . $key . "=" . $value . "|"; } return $strReturn; }
public function confirm_sent() { $this->load->model('checkout/order'); $order_id = $this->session->data['order_id']; $order = $this->model_checkout_order->getOrder($order_id); $current_default_currency = $this->config->get('config_currency'); $bitcoin_btc_decimal = $this->config->get('bitcoin_btc_decimal'); $bitcoin_total = $order['bitcoin_total']; $bitcoin_address = $order['bitcoin_address']; if (!$this->config->get('bitcoin_blockchain')) { require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://' . $this->config->get('bitcoin_rpc_username') . ':' . $this->config->get('bitcoin_rpc_password') . '@' . $this->config->get('bitcoin_rpc_address') . ':' . $this->config->get('bitcoin_rpc_port') . '/'); try { $bitcoin_info = $bitcoin->getinfo(); } catch (Exception $e) { $this->data['error'] = true; } } try { if (!$this->config->get('bitcoin_blockchain')) { $received_amount = $bitcoin->getreceivedbyaddress($bitcoin_address, 0); } else { static $ch = null; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Blockchain.info PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')'); curl_setopt($ch, CURLOPT_URL, 'http://blockchain.info/q/getreceivedbyaddress/' . $bitcoin_address . '?confirmations=0'); $res = curl_exec($ch); if ($res === false) { throw new Exception('Could not get reply: ' . curl_error($ch)); } $received_amount = $res / 100000000; } if (round((double) $received_amount, $bitcoin_btc_decimal) >= round((double) $bitcoin_total, $bitcoin_btc_decimal)) { $order = $this->model_checkout_order->getOrder($order_id); $this->model_checkout_order->confirm($order_id, $this->config->get('bitcoin_order_status_id')); echo "1"; } else { echo "0"; } } catch (Exception $e) { $this->data['error'] = true; echo "0"; } }
public function confirm_sent() { $this->load->model('checkout/order'); $order_id = $this->session->data['order_id']; $order = $this->model_checkout_order->getOrder($order_id); $current_default_currency = "USD"; $hazecoin_total = round($this->currency->convert($order['total'], $current_default_currency, "haze"), 4); require_once 'jsonRPCClient.php'; $hazecoin = new jsonRPCClient('http://' . $this->config->get('hazecoin_rpc_username') . ':' . $this->config->get('hazecoin_rpc_password') . '@' . $this->config->get('hazecoin_rpc_address') . ':' . $this->config->get('hazecoin_rpc_port') . '/'); try { $hazecoin_info = $hazecoin->getinfo(); } catch (Exception $e) { $this->data['error'] = true; } $received_amount = $hazecoin->getreceivedbyaccount($this->config->get('hazecoin_prefix') . '_' . $order_id, 0); if (round((double) $received_amount, 4) >= round((double) $hazecoin_total, 4)) { $order = $this->model_checkout_order->getOrder($order_id); $this->model_checkout_order->confirm($order_id, $this->config->get('hazecoin_order_status_id')); echo true; } else { echo false; } }
function litecoin_link($params) { full_query("CREATE TABLE IF NOT EXISTS `mod_gw_litecoin_payments` (`invoice_id` int(11) NOT NULL, `amount` float(11,8) NOT NULL, `address` varchar(64) NOT NULL, `confirmations` int(11) NOT NULL, PRIMARY KEY (`invoice_id`))"); full_query("CREATE TABLE IF NOT EXISTS `mod_gw_litecoin_info` (`invoice_id` int(11) NOT NULL, `secret` varchar(64) NOT NULL, `address` varchar(64) NOT NULL, PRIMARY KEY (`invoice_id`))"); $q = mysql_fetch_array(mysql_query("SELECT * FROM `mod_gw_litecoin_info` WHERE invoice_id = '{$params['invoiceid']}'")); if ($q['address']) { $amount = $q['amount']; $address = $q['address']; } $secret = ''; $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; for ($i = 0; $i < 64; $i++) { $secret .= substr($characters, rand(0, strlen($characters) - 1), 1); } # Grab the amount and everything from BTC-e's ticker $ltc_ticker = json_decode(file_get_contents("https://btc-e.com/api/2/ltc_usd/ticker"), true); if (!$ltc_ticker) { return "We're sorry, but you cannot use Litecoin to pay for this transaction at this time."; } $amount = round($params['amount'] / $ltc_ticker['ticker']['sell'], 8); # Build Litecoin Information Here require_once 'whmcscoin/jsonRPCClient.php'; $litecoin = new jsonRPCClient("http://{$params['username']}:{$params['password']}@{$params['host']}:{$params['port']}"); if (!$litecoin->getinfo()) { //This won't work. Gotta make this work. return "We're sorry, but you cannot use Litecoin to pay for this transaction at this time."; } $address = $litecoin->getaccountaddress($secret); if (!$address) { //This probably won't work either.{ return "We're sorry, but you cannot use Litecoin to pay for this transaction at this time."; } $code = 'Please send <strong>' . $params['amount'] . '</strong>worth of LTC to address:<br /><strong><a href="#">' . $address . '</a></strong><br /><span id="ltcprice">Currently, ' . $params['amount'] . ' is <strong>' . $amount . '</strong> LTC</span>'; mysql_query("INSERT INTO `mod_gw_litecoin_info` SET invoice_id = '{$params['invoiceid']}', address = '" . mysql_real_escape_string($address) . "', secret = '{$secret}'"); return "<iframe src='{$params['systemurl']}/modules/gateways/litecoin.php?invoice={$params['invoiceid']}' style='border:none; height:120px'>Your browser does not support frames.</iframe>"; return $code; }
$gatewaymodule = "litecoin"; # Enter your gateway module name here replacing template $GATEWAY = getGatewayVariables($gatewaymodule); if (!$GATEWAY["type"]) { die("Module Not Activated"); } # Checks gateway module is active before accepting callback # Gateway Specific Variables $u = $GATEWAY['username']; $p = $GATEWAY['password']; $h = $GATEWAY['host'] . ':' . $GATEWAY['port']; $rpc = 'http://' . $u . ':' . $p . '@' . $h; # Build Litecoin Information Here require_once '../litcoin/jsonRPCClient.php'; $litecoin = new jsonRPCClient($rpc); if (!$litecoin->getinfo()) { die('could not connect to litcoind'); } $sql = 'SELECT * FROM tblinvoices WHERE paymentmethod="' . $gatewaymodule . '" AND status = "Unpaid"'; $results = mysql_query($sql); while ($result = mysql_fetch_array($results)) { $amount = $result['total']; $btcaccount = $result['userid'] . '-' . $result['id']; $received = $litecoin->getbalance($btcaccount); //print($received); if ($amount <= $received) { //echo 'PAID'; $fee = 0; $transid = $litecoin->getaccountaddress($btcaccount . '-' . $result['id']); //checkCbTransID($transid); addInvoicePayment($result['id'], $transid, $received, $fee, $gatewaymodule);
ユーザー名: <input type=text size="40" name="username" value=""><br /> <input type="submit" name="param" value="アドレス取得"> <input type="submit" name="param" value="入金チェック"> </form> <?php require_once __DIR__ . '/jsonRPCClient.php'; $host = 'localhost'; /* monacoind 又は monacoin-qt を実行中のホストのアドレス */ $rpcuser = '******'; /* monacoin.conf で指定した rpcユーザー名 */ $rpcpassword = '******'; /* monacoin.conf で指定した rpcパスワード */ $rpcport = '4000'; /* monacoin.conf で指定した rpcポート */ $historyNum = 50; /* 取得するトランザクション数 */ /* monacoind への接続アドレス */ $coindaddr = "http://{$rpcuser}:{$rpcpassword}@{$host}:{$rpcport}/"; $coind = new jsonRPCClient($coindaddr); $info = $coind->getinfo(); echo "Balance: <div id=balance>{$info['balance']}</div>"; $list = $coind->listaccounts(); print_r($list); ?> <div id="COUNTDOWN">0</div> <div id="BTCMONA">wait</div> </body> </html>
require "jsonRPCClient.php"; session_start(); if (isset($_POST['currentWallet']) && !empty($_POST['currentWallet'])) { $_SESSION['currentWallet'] = $_POST['currentWallet']; } if (isset($_SESSION['currentWallet']) && !empty($_SESSION['currentWallet'])) { $currentWallet = $_SESSION['currentWallet']; } else { $keys = array_keys($wallets); $currentWallet = $keys[0]; $_SESSION['currentWallet'] = $currentWallet; } $nmcu = $wallets[$currentWallet]; $nmc = new jsonRPCClient("{$nmcu['protocol']}://{$nmcu['user']}:{$nmcu['pass']}@{$nmcu['host']}:{$nmcu['port']}", true); try { $nmcinfo = $nmc->getinfo(); } catch (exception $e) { die("Failed to retrieve data from the daemon, please check your configuration, and ensure that your coin daemon is running:<br> {$e}"); } $wallet_encrypted = true; try { $nmc->walletlock(); } catch (Exception $e) { // Wallet is not encrypted $wallet_encrypted = false; } // Begin bootstrap code ?> <!DOCTYPE html> <html lang='en'> <head>
$gatewaymodule = "bitcoin"; # Enter your gateway module name here replacing template $GATEWAY = getGatewayVariables($gatewaymodule); if (!$GATEWAY["type"]) { die("Module Not Activated"); } # Checks gateway module is active before accepting callback # Gateway Specific Variables $u = $GATEWAY['username']; $p = $GATEWAY['password']; $h = $GATEWAY['host'] . ':' . $GATEWAY['port']; $rpc = 'http://' . $u . ':' . $p . '@' . $h; # Build Bitcoin Information Here require_once '../bitcoin/jsonRPCClient.php'; $bitcoin = new jsonRPCClient($rpc); if (!$bitcoin->getinfo()) { die('could not connect to bitcoind'); } $sql = 'SELECT * FROM tblinvoices WHERE paymentmethod="' . $gatewaymodule . '" AND status = "Unpaid"'; $results = mysql_query($sql); while ($result = mysql_fetch_array($results)) { $amount = $result['total']; $btcaccount = $result['userid'] . '-' . $result['id']; $received = $bitcoin->getbalance($btcaccount); //print($received); if ($amount <= $received) { //echo 'PAID'; $fee = 0; $transid = $bitcoin->getaccountaddress($btcaccount . '-' . $result['id']); //checkCbTransID($transid); addInvoicePayment($result['id'], $transid, $received, $fee, $gatewaymodule);
<?php require_once 'jsonRPCClient.php'; $litecoin = new jsonRPCClient('http://*****:*****@127.0.0.1:9332/'); try { $info = $litecoin->getinfo(); } catch (Exception $e) { echo nl2br($e->getMessage()) . '<br />' . "\n"; die; } // Litecoin settings $blockStartingReward = 50; $blockHalvingSubsidy = 840000; $blockTargetSpacing = 2.5; $maxCoins = 84000000; $blocks = $info['blocks']; $coins = CalculateTotalCoins($blockStartingReward, $blocks, $blockHalvingSubsidy); $blocksRemaining = CalculateRemainingBlocks($blocks, $blockHalvingSubsidy); $blocksPerDay = 60 / $blockTargetSpacing * 24; $blockHalvingEstimation = $blocksRemaining / $blocksPerDay * 24 * 60 * 60; $blockString = '+' . $blockHalvingEstimation . ' second'; $blockReward = CalculateRewardPerBlock($blockStartingReward, $blocks, $blockHalvingSubsidy); $coinsRemaining = $blocksRemaining * $blockReward; $nextHalvingHeight = $blocks + $blocksRemaining; $inflationRate = CalculateInflationRate($coins, $blockReward, $blocksPerDay); $inflationRateNextHalving = CalculateInflationRate(CalculateTotalCoins($blockStartingReward, $nextHalvingHeight, $blockHalvingSubsidy), CalculateRewardPerBlock($blockStartingReward, $nextHalvingHeight, $blockHalvingSubsidy), $blocksPerDay); $price = 2.92; // change to dynamic way of getting price function GetHalvings($blocks, $subsidy) { return (int) ($blocks / $subsidy);
function before_process() { global $insert_id, $order; $address = $order->customer['email_address'] . '-' . tep_create_random_value(32); require_once 'bitcoin/jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://' . MODULE_PAYMENT_BITCOIN_LOGIN . ':' . MODULE_PAYMENT_BITCOIN_PASSWORD . '@' . MODULE_PAYMENT_BITCOIN_HOST . '/'); try { $bitcoin->getinfo(); } catch (Exception $e) { $confirmation = array('title' => 'Error: Bitcoin server is down. Please email system administrator regarding your order after confirmation.'); return $confirmation; } $address = $bitcoin->getaccountaddress($address); $order->info['comments'] .= ' | Payment Address: ' . $address . ' | '; return false; }
<?php // ABY WALLET session_start(); include "/var/www/faucet/core/functions.php"; $start = timer(); include "/var/www/faucet/core/config.php"; include_once "/var/www/faucet/core/includes/jsonRPCClient.php"; include "/var/www/faucet/core/address.inc"; include "/var/www/faucet/core/recaptchalib.inc"; include "/var/www/faucet/core/adscaptchalib.inc"; //captha $publickey = "6LffhPUSAAAAAGTZ_L4aju_mxXDa6hJcV6-M_k2a"; $privatekey = "6LffhPUSAAAAAH4Msa5u8ieP4QcEYC2nlnWtHZws"; // init $btclient = new jsonRPCClient("http://" . $btclogin["username"] . ':' . $btclogin["password"] . '@' . $btclogin["host"] . ':' . $btclogin["port"]); $addr = new Address($btclient, $sqlogin); $derp = $btclient->getinfo(); //$this->PDO_Conn = new PDO("mysql:host={$sqllogin['host']};dbname={$sqllogin['dbname']}", $sqllogin['username'], $sqllogin['password']); $dbconn = mysql_connect($sqlogin['host'], $sqlogin['username'], $sqlogin['password']); mysql_select_db($sqlogin['dbname'], $dbconn);
<?php $path = '/var/www/app'; include $path . '/config.php'; require $path . '/jsonRPCClient.php'; $coin = new jsonRPCClient("{$wallet['protocol']}://{$wallet['user']}:{$wallet['pass']}@{$wallet['host']}:{$wallet['port']}"); $staking = $coin->getstakinginfo(); $info = $coin->getinfo(); $newArray = array("averageweight" => $staking['averageweight'], "totalweight" => $staking['totalweight'], "netstakeweight" => $staking['netstakeweight'], "interest" => $coin->getinterest(), "balance" => $info['balance'], "connections" => $info['connections'], "time" => time()); if (!file_exists($path . '/db/stats.dat')) { file_put_contents($path . '/db/stats.dat', serialize(array($newArray))); } else { $array = unserialize(file_get_contents($path . '/db/stats.dat')); array_push($array, $newArray); file_put_contents($path . '/db/stats.dat', serialize($array)); }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); require './config.php'; require './smarty/Smarty.class.php'; require './jsonRPCClient.php'; require './functions.php'; $conn = myinit(); $dd = $conn->query("SELECT * FROM users WHERE username = '******'"); $array = array(); while ($row = $conn->fetch_assoc()) { $array[] = $row; } $i = new jsonRPCClient("http://" . $conf['rpc_user'] . ":" . $conf['rpc_pass'] . "@" . $conf['rpc_host'] . ":" . $conf['rpc_port'] . "/"); $data = $i->getinfo(); $smarty = new Smarty(); //$smarty->force_compile = true; $smarty->debugging = true; $smarty->caching = false; $smarty->assign('data', $df); $smarty->display('index.tpl');
public static function getInfo() { $wallet = new jsonRPCClient(HOTWALLET, true); $getInfo = $wallet->getinfo(); return $getInfo; }
include "config/config.php"; require_once 'jsonrpcphp/includes/jsonRPCClient.php'; include "includes/infomsg.php"; $khs = 0; print "<html>"; print "<head>"; print "<title>Test script</title>"; print "<meta http-equiv=\"refresh\" content=\"60\" />"; print "</head>"; print "</body>"; print "<center> <img src=\"logos/" . $symbol . ".png\"></center><br/>"; print "<center><font size=\"10\">" . $name . " Faucet.</font></center><br/>"; $bitcoin = new jsonRPCClient('http://' . $user . ':' . $password . '@' . $host . ':' . $port . '/'); // print_r($bitcoin->getmininginfo()); $array = $bitcoin->getmininginfo(); $array2 = $bitcoin->getinfo(); if (array_key_exists('networkhashps', $bitcoin->getmininginfo())) { $khs = $array['networkhashps']; $kname = "KH's"; } if (array_key_exists('netmhashps', $bitcoin->getmininginfo())) { $kname = "MH's"; $khs = $array['netmhashps']; } /* #Needs finishing. #if (array_key_exists('Proof-of-Stake', $bitcoin->getinfo())) #{ #$PoS = $array[1]['Proof-of-Stake']; #} */
public function is_testnet() { try { $r = parent::getinfo(); if ($r['testnet']) { return true; } } catch (Exception $e) { return false; } return false; }
<?php require_once 'settings.php'; if ($login) { require_once 'login.php'; } require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient($address); require_once 'functions.php'; $getinfo = $bitcoin->getinfo(); $getpeerinfo = $bitcoin->getpeerinfo(); $getaddednodeinfo = $bitcoin->getaddednodeinfo(false); $getblockchaininfo = $bitcoin->getblockchaininfo();
$startTime = microtime(true); if (PHP_SAPI != 'cli') { ob_start(); } require __DIR__ . '/config.php'; require __DIR__ . '/function.php'; require __DIR__ . '/jsonRPCClient.php'; require __DIR__ . '/name.class.php'; if (isset($showDebug) && $showDebug) { error_reporting(E_ALL ^ E_NOTICE); ini_set('display_errors', 'On'); } ini_set('memory_limit', 200 * 1024 * 1024); // $rpc = new jsonRPCClient($jsonConnect); $getinfo = $rpc->getinfo(); if (!($getinfo_old = get_cache('getinfo'))) { $getinfo_old = array('blocks' => 0); } if ($getinfo['blocks'] == $getinfo_old['blocks']) { echo 'Still on same block'; exit; } echo "New blocks : " . ($getinfo['blocks'] - $getinfo_old['blocks']) . "\n"; showDebug(0); // $diff = $getinfo['blocks'] - $getinfo_old['blocks']; $new_names = $rpc->name_filter("^d/[a-z0-9_-]+\$", $diff); #echo '<pre>'; print_r($new_names); if (!count($new_names)) { echo 'No new name since last scan';
if ($blockchain != 'multi') { try { $bitcoind = new jsonRPCClient("http://" . $rpc_options[$blockchain]['username'] . ":" . $rpc_options[$blockchain]['password'] . "@" . $rpc_options[$blockchain]['host'] . ":" . $rpc_options[$blockchain]['port'] . "/"); if ($bitcoind->getinfo()) { $loaded = true; } } catch (Exception $e) { $loaded = false; } } if ($loaded === true || $blockchain == 'multi') { if ($blockchain != 'multi') { $bitcoind = new jsonRPCClient("http://" . $rpc_options[$blockchain]['username'] . ":" . $rpc_options[$blockchain]['password'] . "@" . $rpc_options[$blockchain]['host'] . ":" . $rpc_options[$blockchain]['port'] . "/"); $raw = false; if ($debug && $bitcoind && $loaded) { $raw = $bitcoind->getinfo(); } } if ($call == 'address') { $obj = ["address" => false, "blockchain" => $blockchain, "hash" => "N/A", "tx_count" => 0, "received" => 0, "balance" => 0, "raw" => []]; if (isset($_GET['id']) && $_GET['id']) { $address = $_GET['id']; $obj['address'] = $address; $account_name = 'XXX_' . $address; $balance = $bitcoind->getbalance($account_name, 1, true); $received = $bitcoind->getreceivedbyaccount($account_name, 1); $address = $bitcoind->validateaddress($obj['address']); $txs = $bitcoind->listtransactions($account_name, 100, 0, true); foreach ($txs as $tx_key => $tx) { $raw_tx = $bitcoind->getrawtransaction($tx['txid'], 1); foreach ($raw_tx['vout'] as $output) {