diff --git a/index.html b/index.html index dfdbc05..d349c80 100644 --- a/index.html +++ b/index.html @@ -1300,9 +1300,10 @@ Sig Hash Type - ALL (default) + ALL NONE SINGLE + ALL|FORKID (default) ALL|ANYONECANPAY NONE|ANYONECANPAY SINGLE|ANYONECANPAY diff --git a/js/coin.js b/js/coin.js index d144f1f..baafeb6 100644 --- a/js/coin.js +++ b/js/coin.js @@ -22,10 +22,8 @@ coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; // Bitcoin /* bit(coinb.in) api vars */ - coinjs.hostname = ((document.location.hostname.split(".")[(document.location.hostname.split(".")).length-1]) == 'onion') ? 'coinbin3ravkwb24f7rmxx6w3snkjw45jhs5lxbh3yfeg3vpt6janwqd.onion' : 'coinb.in'; - coinjs.host = ('https:'==document.location.protocol?'https://':'http://')+coinjs.hostname+'/api/'; - coinjs.uid = '1'; - coinjs.key = '12345678901234567890123456789012'; + coinjs.hostname = ((document.location.hostname.split(".")[(document.location.hostname.split(".")).length-1]) == 'onion') ? 'coinbin3ravkwb24f7rmxx6w3snkjw45jhs5lxbh3yfeg3vpt6janwqd.onion' : 'api.avn.network'; + coinjs.host = ('https:'==document.location.protocol?'https://':'https://')+coinjs.hostname; /* start of address functions */ @@ -321,7 +319,7 @@ /* retreive the balance from a given address */ coinjs.addressBalance = function(address, callback){ - coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=addresses&request=bal&address='+address+'&r='+Math.random(), callback, "GET"); + coinjs.ajax(coinjs.host+'/balance/='+address, callback, "GET"); } /* decompress an compressed public key */ @@ -1064,12 +1062,12 @@ /* list unspent transactions */ r.listUnspent = function(address, callback) { - coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=addresses&request=unspent&address='+address+'&r='+Math.random(), callback, "GET"); + coinjs.ajax(coinjs.host+'/unspent/'+address+'?amount=1', callback, "GET"); } /* list transaction data */ r.getTransaction = function(txid, callback) { - coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=avian&request=gettransaction&txid='+txid+'&r='+Math.random(), callback, "GET"); + coinjs.ajax(coinjs.host+'/transaction/'+txid, callback, "GET"); } /* add unspent to transaction */ @@ -1140,7 +1138,7 @@ /* broadcast a transaction */ r.broadcast = function(callback, txhex){ var tx = txhex || this.serialize(); - coinjs.ajax(coinjs.host+'?uid='+coinjs.uid+'&key='+coinjs.key+'&setmodule=avian&request=sendrawtransaction', callback, "POST", ["rawtx="+tx]); + coinjs.ajax(coinjs.host+'/broadcast/', callback, "POST", ["raw="+tx]); } /* generate the transaction hash to sign from a transaction input */ diff --git a/js/coinbin.js b/js/coinbin.js index fa36506..b35bd3f 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -4,7 +4,7 @@ $(document).ready(function() { var explorer_tx = "https://explorer.avn.network/tx/" var explorer_addr = "https://explorer.avn.network/addr/" - var explorer_block = "https:/explorer.avn.network/block/" + var explorer_block = "https://explorer.avn.network/block/" var wallet_timer = false; @@ -1083,9 +1083,10 @@ $(document).ready(function() { if(redeem.addr) { $("#redeemFromAddress").removeClass('hidden').html(' Retrieved unspent inputs from address '+redeem.addr+''); - $.each($(data).find("unspent").children(), function(i,o){ - var tx = $(o).find("tx_hash").text(); - var n = $(o).find("tx_output_n").text(); + let results = JSON.parse(data); + $.each($(data.result).find().children(), function(i,o){ + var tx = $(o).find("txid").text(); + var n = $(o).find("index").text(); var script = (redeem.redeemscript==true) ? redeem.decodedRs : $(o).find("script").text(); var amount = (($(o).find("value").text()*1)/100000000).toFixed(8); @@ -1112,9 +1113,16 @@ $(document).ready(function() { success: function(data) { if(data.result && data.error == null){ $("#redeemFromAddress").removeClass('hidden').html(' Retrieved unspent inputs from address '+redeem.addr+''); - data.result.forEach(i => { - addOutput(i.txid, i.index+1, i.script, (i.value/100000000)); - }); + for(var i in data.result){ + var o = data.result[i]; + var tx = ((""+o.txid).match(/.{1,2}/g).reverse()).join("")+''; + if(tx.match(/^[a-f0-9]+$/)){ + var n = o.index; + var script = (redeem.redeemscript==true) ? redeem.decodedRs : o.script; + var amount = o.value; + addOutput(tx, n, script, amount); + } + } } else { $("#redeemFromStatus").removeClass('hidden').html(' Unexpected error, unable to retrieve unspent outputs.'); } @@ -1168,6 +1176,7 @@ $(document).ready(function() { function totalFee(){ var fee = (($("#totalInput").html()*1) - ($("#totalOutput").html()*1)).toFixed(8); $("#transactionFee").val((fee>0)?fee:'0.00'); + $("#transactionFee").val('0.001'); } $(".optionsCollapse").click(function(){