Skip to content

Commit

Permalink
new api
Browse files Browse the repository at this point in the history
  • Loading branch information
darekw committed Oct 18, 2013
1 parent b4a4b3e commit f587aa1
Showing 1 changed file with 53 additions and 18 deletions.
71 changes: 53 additions & 18 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,68 @@
jQuery(document).ready(function(){
InitAll4btc();
});

var bitcoin = bitcoin || {
getClientInfo: function (callback) {
var info = {
firstname: 'Homer',
lastname: 'Simpson',
email: 'homer@fake.com',
address: 'poqjer23rfc234laq',
street: 'next to Flanders',
zipcode: '12233',
city: 'Springfield',
country: 'USA'
};
BTC_IN_SATOSHI: 100000000,
MBTC_IN_SATOSHI: 100000,
UBTC_IN_SATOSHI: 100,

return callback(info);
sendMoney: function(hash, amount, callback){
if (!hash){
throw "hash argument is undefined";
}
if (callback){
callback(true, 'FAKE_HASH');
}
},

sendCoins: function (hash, amount, callback) {
return callback(true, hash);
getTransaction: function(id, callback){
if (!id || !callback){
throw "id and callback are required";
}
return {
id: 123,
amount: 10,
received: true,
timestamp: new Date(),
inputAddresses: ['HASH1'],
outputAddresses: ['HASH2']
}
},

getUserInfo: function(callback){
if (!callback){
throw "callback is required";
}
return {
firstName: 'Homer',
lastName: 'Simpson',
email: 'homer@fake.com',
address: 'poqjer23rfc234laq',
};
}
};


function btc_string_to_satoshi(x){
var tab = [];
if (x.indexOf('.') > 0 ){
tab = x.split('.');
}else if (x.indexOf(',') > 0){
tab = x.split(',');
}else{
tab = [x,'0'];
}
var count = tab[1].length;
tab = [parseInt(tab[0]), parseInt(tab[1])];
amount = tab[0]*bitcoin.BTC_IN_SATOSHI + tab[1]*(bitcoin.BTC_IN_SATOSHI/(Math.pow(10,count)));
return amount;
}

function payCoins(sNumber, btcprice)
{
jQuery('#loading-page').hide();
//alert('payCoins:'+sNumber+';'+btcprice);
bitcoin.sendCoinsForAddress(sNumber, btcprice, function(status, transaction_hash){
btcprice = btc_string_to_satoshi(sNumber);
bitcoin.sendMoney(sNumber, btcprice, function(status, transaction_hash){
if (status == true){
animatePage('.page','#end-page');
}
Expand Down

0 comments on commit f587aa1

Please sign in to comment.