Skip to content

Commit

Permalink
minor bug fix from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
OutCast3k committed Aug 14, 2015
1 parent a1c3c60 commit 8e0742d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
35 changes: 17 additions & 18 deletions js/coinbin.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ $(document).ready(function() {
/* redeem from button code */

$("#redeemFromBtn").click(function(){
var string = $("#redeemFrom").val();
var redeem = redeemingFrom(string);
var redeem = redeemingFrom($("#redeemFrom").val());

$("#redeemFromStatus, #redeemFromAddress").addClass('hidden');

Expand All @@ -533,11 +532,11 @@ $(document).ready(function() {

var host = $(this).attr('rel');
if(host=='blockr.io_bitcoinmainnet'){
listUnspentBlockrio_BitcoinMainnet(redeem.addr);
listUnspentBlockrio_BitcoinMainnet(redeem);
} else if(host=='chain.so_litecoin'){
listUnspentChainso_Litecoin(redeem.addr);
listUnspentChainso_Litecoin(redeem);
} else {
listUnspentDefault(redeem.addr);
listUnspentDefault(redeem);
}
});

Expand Down Expand Up @@ -593,16 +592,16 @@ $(document).ready(function() {
}

/* default function to retreive unspent outputs*/
function listUnspentDefault(addr){
function listUnspentDefault(redeem){
var tx = coinjs.transaction();
tx.listUnspent(addr, function(data){
if(addr) {
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+addr+'" target="_blank">'+addr+'</a>');
tx.listUnspent(redeem.addr, function(data){
if(redeem.addr) {
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+redeem.addr+'" target="_blank">'+redeem.addr+'</a>');

$.each($(data).find("unspent").children(), function(i,o){
var tx = $(o).find("tx_hash").text();
var n = $(o).find("tx_output_n").text();
var script = (addr.isMultisig==true) ? $("#inputs .txIdScript:last").val(string) :$(o).find("script").text();
var script = (redeem.isMultisig==true) ? $("#redeemFrom").val() : $(o).find("script").text();
var amount = (($(o).find("value").text()*1)/100000000).toFixed(8);

addOutput(tx, n, script, amount);
Expand All @@ -615,22 +614,22 @@ $(document).ready(function() {
}

/* retrieve unspent data from blockrio for mainnet */
function listUnspentBlockrio_BitcoinMainnet(addr){
function listUnspentBlockrio_BitcoinMainnet(redeem){
$.ajax ({
type: "POST",
url: "https://btc.blockr.io/api/v1/address/unspent/"+addr,
url: "https://btc.blockr.io/api/v1/address/unspent/"+redeem.addr,
dataType: "json",
error: function(data) {
$("#redeemFromStatus").removeClass('hidden').html('<span class="glyphicon glyphicon-exclamation-sign"></span> Unexpected error, unable to retrieve unspent outputs!');
},
success: function(data) {
if((data.status && data.data) && data.status=='success'){
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+addr+'" target="_blank">'+addr+'</a>');
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+redeem.addr+'" target="_blank">'+redeem.addr+'</a>');
for(var i in data.data.unspent){
var o = data.data.unspent[i];
var tx = o.tx;
var n = o.n;
var script = o.script;
var script = (redeem.isMultisig==true) ? $("#redeemFrom").val() : o.script;
var amount = o.amount;
addOutput(tx, n, script, amount);
}
Expand All @@ -646,23 +645,23 @@ $(document).ready(function() {
}

/* retrieve unspent data from blockrio for litecoin */
function listUnspentChainso_Litecoin(addr){
function listUnspentChainso_Litecoin(redeem){
$.ajax ({
type: "GET",
url: "https://chain.so/api/v2/get_tx_unspent/ltc/"+addr,
url: "https://chain.so/api/v2/get_tx_unspent/ltc/"+redeem.addr,
dataType: "json",
error: function(data) {
$("#redeemFromStatus").removeClass('hidden').html('<span class="glyphicon glyphicon-exclamation-sign"></span> Unexpected error, unable to retrieve unspent outputs!');
},
success: function(data) {
console.log(data);
if((data.status && data.data) && data.status=='success'){
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+addr+'" target="_blank">'+addr+'</a>');
$("#redeemFromAddress").removeClass('hidden').html('<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="https://btc.blockr.io/address/info/'+redeem.addr+'" target="_blank">'+redeem.addr+'</a>');
for(var i in data.data.txs){
var o = data.data.txs[i];
var tx = o.txid;
var n = o.output_no;
var script = o.script_hex;
var script = (redeem.isMultisig==true) ? $("#redeemFrom").val() : o.script_hex;
var amount = o.value;
addOutput(tx, n, script, amount);
}
Expand Down
8 changes: 4 additions & 4 deletions sha1sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---- Version 1.2 2015.07.27 ----
---- Version 1.2 2015.08.14 ----
e6810907c901e6bd34a28735a68850936f0823b8 ./js/ellipticcurve.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
Expand All @@ -11,7 +11,7 @@ ad038e1f39646b68ae666324ed4c2882a8c42474 ./js/qrcode.js
64eb4ea5c882f8bce3e1885bf00728455f1c2f4c ./js/ripemd160.js
114089ef2a3feb6d4db4f9cabcb186d7750d5884 ./js/sha512.js
8c2654113866b4a57fec302665ca2187a3eb7614 ./js/coin.js
e544bb942aeb35a18a4cd7e0b440e6bba7a8e04f ./js/coinbin.js
4b24ab93c1cb7068d5396d0794b2818c6a889daa ./js/coinbin.js
ae49e56999d82802727455f0ba83b63acd90a22b ./js/jquery-1.9.1.min.js
5f570018ed044eafd464f7e0ab1783b966224055 ./LICENCE
ed29315e0ffb3f14382431f2724235bf67f44eb3 ./css/bootstrap.min.css
Expand All @@ -24,5 +24,5 @@ ca35b697d99cae4d1b60f2d60fcd37771987eb07 ./fonts/glyphicons-halflings-regular.w
de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.svg
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
fe8d57914bb036ab94e86ec35b2671eeb6d20d0d ./README.md
f8d50a5ea3a06edacf2948f150221e027f1c1253 ./index.html
0f5262c7910512cdcf38a6004129154be77ff2ee ./README.md
0ed7525c0504e2cb967f9fb0f9708fe6a345bfa6 ./index.html

0 comments on commit 8e0742d

Please sign in to comment.