Skip to content

Instantly share code, notes, and snippets.

@drizzt
Created January 23, 2017 09:22
Show Gist options
  • Save drizzt/00a5de9cb140f2fb980a5c4dde0022bf to your computer and use it in GitHub Desktop.
Save drizzt/00a5de9cb140f2fb980a5c4dde0022bf to your computer and use it in GitHub Desktop.
<?php
require 'xpub.php';
?>
<html>
<head></head>
<body>
<script src="//blockr.io/js_external/coinwidget/coin.js"></script>
<script>
CoinWidgetCom.go({
wallet_address: '<?php echo(get_bitcoin_address('xpub6CWiJoiwxPQni3DFbrQNHWq8kwrL2J1HuBN7zm4xKPCZRmEshc7Dojz4zMah7E4o2GEEbD6HgfG7sQid186Fw9x9akMNKw2mu1PjqacTJB2')); ?>',
currency: 'bitcoin',
counter: 'hide',
lbl_button: 'Donate',
lbl_count: 'donations',
lbl_amount: 'BTC',
lbl_address: 'Use address below to donate. Thanks!',
qrcode: true,
alignment: 'bl',
decimals: 8,
size: "big",
color: "dark",
countdownFrom: "0",
element: "#coinwidget-bitcoin",
onShow: function(){},
onHide: function(){}
});
</script>
<div id="coinwidget-bitcoin"></div>
</body>
</html>
<?php
function url_get_contents ($url) {
if (function_exists('curl_exec')) {
$conn = curl_init($url);
curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($conn, CURLOPT_FRESH_CONNECT, true);
curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
$url_get_contents_data = (curl_exec($conn));
curl_close($conn);
} elseif(function_exists('file_get_contents')) {
$url_get_contents_data = file_get_contents($url);
} elseif(function_exists('fopen') && function_exists('stream_get_contents')) {
$handle = fopen ($url, "r");
$url_get_contents_data = stream_get_contents($handle);
} else {
$url_get_contents_data = false;
}
return $url_get_contents_data;
}
function get_bitcoin_address($xpub) {
$url = "https://api.smartbit.com.au/v1/blockchain/address/$xpub?tx=0";
$j = json_decode(url_get_contents($url), true);
return $j["address"]["extkey_next_receiving_address"];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment