From c7a0fda7e546a98670a3894b47dba43978e96cd1 Mon Sep 17 00:00:00 2001 From: Wowee0 Date: Fri, 19 Apr 2019 10:40:59 -0500 Subject: [PATCH] re-enabled Litecoin --- index.html | 2 ++ js/coinbin.js | 47 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 323edc3..6d3f3f0 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 01b0cce..f9c67a6 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.'); @@ -1294,6 +1296,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); @@ -1823,6 +1856,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);