It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
// IMPORTANT!
// This is NOT SECURE by default, restrict access to this script,
// password protect it, check the referrer, session, or whatever else you like.
// Anyone able to reach this script AS IS is able to send your balance to another address!
// simply call commands like this
// ./SAMPLE_JSON.PHP?command=getinfo
// or with parameter
// ./SAMPLE_JSON.PHP?command=getnewaddress¶meter=username
// ./SAMPLE_JSON.PHP?command=getreceivedbylabel¶meter=username
// set the URL to JSON-API
$url = 'http://127.0.0.1:8332';
// set a JSON id
$jsonid = 'unique';
// which command has been called?
if ($_GET['command'])
$command = $_GET['command'];
// and if what parameter?
if ($_GET['parameter'])
$para = $_GET['parameter'];
if ($para) $parb = array($para);
// if none, we create an empty array
else $parb = array();
// and encode all of it to JSON
$arr = array (
'id'=>$jsonid,
'method'=>$command,
'params'=>$parb
);
$data = json_encode($arr);
// run cURL to transfer our data
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
// debug - to check the response we can just view our JSON output here
echo $output."
\n\r";
// if $output looks ok, we decode it here and close our cURL session
$obj = json_decode($output);
curl_close($ch);
// and that's it, just handle the $obj and show it, add/compare it to DBs, or whatever else is needed.
// below is just some basic samples
if ($obj->error != "null")
echo $obj->error;
if ($obj->id == $jsonid) {
if (is_object($obj->result))
$info = get_object_vars($obj->result);
if ($command == "getinfo") {
if ($info) {
echo "Balance: ". $info['balance']."
\n\r";
echo "Blocks: ". $info['blocks']."
\n\r";
echo "Connections: ". $info['connections']."
\n\r";
if ($info['generate'])
$gen = "yes";
else
$gen = "no";
echo "Generating: ". $gen."
\n\r";
echo "Difficulty: ". $info['difficulty']."
\n\r";
}
}
if ($command == "getreceivedbylabel") {
echo $obj->result."\n";
}
if ($command == "getnewaddress") {
echo $obj->result."\n";
}
}
?>
#! /usr/bin/python
import jsonrpc
import time
import datetime
from database import *
class BitcoinInterface(object):
def __init__(self):
self.access = jsonrpc.ServiceProxy("http://127.0.0.1:8332")
return
def issueBitcoinAddresses(self):
localBitcoinAddresses = list(Address.select(AND(Address.q.type_ == "localBitcoin", Address.q.value == None))) # Get all unassigned local Bitcoin Addresses
for localBitcoinAddress in localBitcoinAddresses:
localBitcoinAddress.value = self.access.getnewaddress()
client = Client.get(localBitcoinAddress.clientID)
print "New Address:\nUsername: %s\nClientID: %i\nValue: %s\n" % (client.username, client.id, localBitcoinAddress.value)
return
def takeDeposits(self):
localBitcoinAddresses = list(Address.select(AND(Address.q.type_ == "localBitcoin", Address.q.value != None))) # Get all assigned local Bitcoin Addresses
for localBitcoinAddress in localBitcoinAddresses:
amountReceived = self.access.getamountreceived(localBitcoinAddress.value)
if amountReceived > localBitcoinAddress.amountReceived:
client = Client.get(localBitcoinAddress.clientID)
quantity = amountReceived - localBitcoinAddress.amountReceived
client.bitcoins = client.bitcoins + quantity
localBitcoinAddress.amountReceived = amountReceived
transaction = Transaction(clientID = client.id)
transaction.datetime = datetime.datetime.now()
transaction.type_ = "Deposit"
transaction.quantity = quantity # Transaction quantity is positive for "Deposit"
print "Deposit:\nUsername: %s\nClientID: %i\nQuantity: %f\n" % (client.username, client.id, quantity)
return
def issueWithdrawals(self):
clients = list(Client.select(Client.q.bitcoinsToWithdraw > 0))
for client in clients:
if client.bitcoinsToWithdraw <= client.bitcoins: # Redundancy check
foreignBitcoinAddress = list(Address.select(AND(Address.q.clientID == client.id, Address.q.type_ == "foreignBitcoin")))[0]
try:
quantity = client.bitcoinsToWithdraw
self.access.sendtoaddress(foreignBitcoinAddress.value, quantity)
client.bitcoins = client.bitcoins - quantity
transaction = Transaction(clientID = client.id)
transaction.datetime = datetime.datetime.now()
transaction.type_ = "Withdrawal"
transaction.quantity = -quantity # Transaction quantity is negative for "Withdrawal"
client.bitcoinsToWithdraw = 0
print "Withdrawal:\nUsername: %s\nClientID: %i\nQuantity: %f\n" % (client.username, client.id, quantity)
except:
print "Failed Withdrawal:\nUsername: %s\nClientID: %i\nQuantity: %f\n" % (client.username, client.id, client.bitcoinsToWithdraw)
else:
print "Failed Withdrawal, Not Enough Bitcoins:\nUsername: %s\nClientID: %i\n" % (client.username, client.id)
return
bitcoinInterface = BitcoinInterface()
while 1:
bitcoinInterface.issueBitcoinAddresses()
bitcoinInterface.takeDeposits()
bitcoinInterface.issueWithdrawals()
time.sleep(300)
#!/usr/bin/python
import jsonrpc
MyBCAddress = 'YOUR BITCOIN ADDRESS HERE'
b = jsonrpc.ServiceProxy("http://localhost:8332/")
bal = float(b.getbalance())
if bal > 0.01:
print "We have a balance of {0:.2f}BC. Sending...".format(bal)
b.sendtoaddress(MyBCAddress,bal)
else:
print "No coins here."