Add files via upload

This commit is contained in:
Tom Carbon 2016-09-03 22:20:09 -07:00 committed by GitHub
parent 0c3530590f
commit 85c9267379
2 changed files with 78 additions and 3 deletions

View file

@ -702,7 +702,7 @@
r.spendToScript = function(address){ r.spendToScript = function(address){
var addr = coinjs.addressDecode(address); var addr = coinjs.addressDecode(address);
var s = coinjs.script(); var s = coinjs.script();
if(addr.version==5){ // multisig address if(addr.version==coinjs.multisig){ // multisig address
s.writeOp(169); //OP_HASH160 s.writeOp(169); //OP_HASH160
s.writeBytes(addr.bytes); s.writeBytes(addr.bytes);
s.writeOp(135); //OP_EQUAL s.writeOp(135); //OP_EQUAL

View file

@ -683,6 +683,8 @@ $(document).ready(function() {
listUnspentBlockrio_BitcoinMainnet(redeem); listUnspentBlockrio_BitcoinMainnet(redeem);
} else if(host=='chain.so_litecoin'){ } else if(host=='chain.so_litecoin'){
listUnspentChainso_Litecoin(redeem); listUnspentChainso_Litecoin(redeem);
} else if(host=='chain.so_dogecoin'){
listUnspentChainso_Dogecoin(redeem);
} else { } else {
listUnspentDefault(redeem); listUnspentDefault(redeem);
} }
@ -869,6 +871,40 @@ $(document).ready(function() {
}); });
} }
/* retrieve unspent data from chain.so for dogecoin */
function listUnspentChainso_Dogecoin(redeem){
$.ajax ({
type: "GET",
url: "https://chain.so/api/v2/get_tx_unspent/doge/"+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/'+
redeem.addr+'" target="_blank">'+redeem.addr+'</a>');
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.isMultisig==true) ? $("#redeemFrom").val() : o.script_hex;
var amount = o.value;
addOutput(tx, n, script, amount);
}
} else {
$("#redeemFromStatus").removeClass('hidden').html('<span class="glyphicon glyphicon-exclamation-sign"></span> Unexpected error, unable to retrieve unspent outputs.');
}
},
complete: function(data, status) {
$("#redeemFromBtn").html("Load").attr('disabled',false);
totalInputAmount();
}
});
}
/* math to calculate the inputs and outputs */ /* math to calculate the inputs and outputs */
function totalInputAmount(){ function totalInputAmount(){
@ -1073,6 +1109,43 @@ $(document).ready(function() {
}); });
} }
// broadcast transaction via chain.so for dogecoin
function rawSubmitchainso_dogecoin(thisbtn){
$(thisbtn).val('Please wait, loading...').attr('disabled',true);
$.ajax ({
type: "POST",
url: "https://chain.so/api/v2/send_tx/DOGE",
data: {"tx_hex":$("#rawTransaction").val()},
dataType: "json",
error: function(data) {
var obj = $.parseJSON(data.responseText);
var r = ' ';
r += (obj.data) ? obj.data : '';
r += (obj.message) ? ' '+obj.message : '';
r = (r!='') ? r : ' Failed to broadcast'; // build response
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
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('<span class="glyphicon glyphicon-exclamation-sign"></span>');
}
},
complete: function(data, status) {
$("#rawTransactionStatus").fadeOut().fadeIn();
$(thisbtn).val('Submit').attr('disabled',false);
}
});
}
/* verify script code */ /* verify script code */
$("#verifyBtn").click(function(){ $("#verifyBtn").click(function(){
@ -1362,8 +1435,6 @@ $(document).ready(function() {
return r; return r;
} }
$("#newKeysBtn, #newHDKeysBtn").click();
var _getBroadcast = _get("broadcast"); var _getBroadcast = _get("broadcast");
if(_getBroadcast[0]){ if(_getBroadcast[0]){
$("#rawTransaction").val(_getBroadcast[0]); $("#rawTransaction").val(_getBroadcast[0]);
@ -1533,6 +1604,10 @@ $(document).ready(function() {
$("#rawSubmitBtn").click(function(){ $("#rawSubmitBtn").click(function(){
rawSubmitChainso_BitcoinMainnet(this); rawSubmitChainso_BitcoinMainnet(this);
}); });
} else if(host=="chain.so_dogecoin"){
$("#rawSubmitBtn").click(function(){
rawSubmitchainso_dogecoin(this);
});
} else if(host=="blockcypher_bitcoinmainnet"){ } else if(host=="blockcypher_bitcoinmainnet"){
$("#rawSubmitBtn").click(function(){ $("#rawSubmitBtn").click(function(){
rawSubmitblockcypher_BitcoinMainnet(this); rawSubmitblockcypher_BitcoinMainnet(this);