diff --git a/index.html b/index.html index 5f387a5..bf1098d 100644 --- a/index.html +++ b/index.html @@ -1334,6 +1334,7 @@

Select which network you'd like to use for key pair generation.

diff --git a/js/coinbin.js b/js/coinbin.js index c287ddb..475c9c8 100644 --- a/js/coinbin.js +++ b/js/coinbin.js @@ -1037,11 +1037,13 @@ $(document).ready(function() { $("#redeemFromAddress").removeClass('hidden').html(' Retrieved unspent inputs from address '+redeem.addr+''); for(var i in data.data.txs){ var o = data.data.txs[i]; - var tx = ((o.txid).match(/.{1,2}/g).reverse()).join("")+''; - var n = o.output_no; - var script = (redeem.redeemscript==true) ? redeem.decodedRs : o.script_hex; - var amount = o.value; - addOutput(tx, n, script, amount); + var tx = ((""+o.txid).match(/.{1,2}/g).reverse()).join("")+''; + if(tx.match(/^[a-f0-9]+$/)){ + var n = o.output_no; + var script = (redeem.redeemscript==true) ? redeem.decodedRs : o.script_hex; + var amount = o.value; + addOutput(tx, n, script, amount); + } } } else { $("#redeemFromStatus").removeClass('hidden').html(' Unexpected error, unable to retrieve unspent outputs.'); @@ -1292,6 +1294,37 @@ $(document).ready(function() { } + // broadcast transaction via chain.so for litecoin + function rawSubmitchainso_litecoin(thisbtn){ + $(thisbtn).val('Please wait, loading...').attr('disabled',true); + $.ajax ({ + type: "POST", + url: "https://chain.so/api/v2/send_tx/LTC", + data: {"tx_hex":$("#rawTransaction").val()}, + dataType: "json", + error: function(data) { + var obj = $.parseJSON(data.responseText); + var r = ' '; + r += (obj.data.tx_hex) ? ' '+obj.data.tx_hex : ''; + r = (r!='') ? r : ' Failed to broadcast'; // build response + $("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend(''); + // console.error(JSON.stringify(data, null, 4)); + }, + success: function(data) { + // console.info(JSON.stringify(data, null, 4)); + if((data.status && data.data) && data.status=='success'){ + $("#rawTransactionStatus").addClass('alert-success').removeClass('alert-danger').removeClass("hidden").html(' Txid: ' + data.data.txid); + } else { + $("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(' Unexpected error, please try again').prepend(''); + } + }, + complete: function(data, status) { + $("#rawTransactionStatus").fadeOut().fadeIn(); + $(thisbtn).val('Submit').attr('disabled',false); + } + }); + } + // broadcast transaction via chain.so for dogecoin function rawSubmitchainso_dogecoin(thisbtn){ $(thisbtn).val('Please wait, loading...').attr('disabled',true); @@ -1771,6 +1804,14 @@ $(document).ready(function() { configureBroadcast(); configureGetUnspentTx(); + if (coinjs.pub == 0x30){ // LTC + explorer_addr = "https://chain.so/address/LTC/"; + coinjs.bech32.hrp = "ltc"; + } + else if (coinjs.pub == 0x1e){ // DOGE + explorer_addr = "https://chain.so/address/DOGE/"; + } + $("#statusSettings").addClass("alert-success").removeClass("hidden").html(" Settings updates successfully").fadeOut().fadeIn(); } else { $("#statusSettings").addClass("alert-danger").removeClass("hidden").html("There is an error with one or more of your settings"); @@ -1821,6 +1862,10 @@ $(document).ready(function() { $("#rawSubmitBtn").click(function(){ rawSubmitChainso_BitcoinMainnet(this); }); + } else if(host=="chain.so_litecoin"){ + $("#rawSubmitBtn").click(function(){ + rawSubmitchainso_litecoin(this); + }); } else if(host=="chain.so_dogecoin"){ $("#rawSubmitBtn").click(function(){ rawSubmitchainso_dogecoin(this);