Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add digibyte support #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,9 @@ <h2>Settings <small> making coinb.in even better!</small></h2>
<p class="text-muted">Select which network you'd like to use for key pair generation.</p>
<select class="form-control" id="coinjs_coin">
<option value="bitcoin_mainnet" rel="0x00;0x80;0x05;0x488b21e;0x488ade4;coinb.in;coinb.in">Bitcoin (mainnet)</option>
<option value="dogecoin_mainnet" rel="0x1e;0x9e;0x16;0x0827421e;0x089944e4;chain.so_dogecoin;chain.so_dogecoin">Dogecoin (mainnet)</option>
<option value="carboncoin_mainnet" rel="0x2f;0xaf;0x05;0x488b21e;0x488ade4;cryptoid.info_carboncoin;cryptoid.info_carboncoin">Carboncoin (mainnet)</option>
<option value="digibyte_mainnet" rel="0x1e;0x80;0x3f;0x488b21e;0x488ade4;digiexplorer.info;digiexplorer.info">DigiByte (mainnet)</option>
<option value="dogecoin_mainnet" rel="0x1e;0x9e;0x16;0x0827421e;0x089944e4;chain.so_dogecoin;chain.so_dogecoin">Dogecoin (mainnet)</option>
<option value="shadowcash_mainnet" rel="0x3f;0xbf;0x7d;0xee80286a;0xee8031e8;false;false">ShadowCash (mainnet)</option>
<option value="bitcoin_testnet" rel="0x6f;0xef;0xc4;0x043587cf;0x04358394;false;false">Bitcoin (testnet)</option>

Expand Down Expand Up @@ -1373,6 +1374,7 @@ <h2>Settings <small> making coinb.in even better!</small></h2>
<option value="coinb.in">coinb.in (Bitcoin mainnet)</option>
<option value="chain.so_bitcoinmainnet"> Chain.so (Bitcoin mainnet)</option>
<option value="blockcypher_bitcoinmainnet"> Blockcypher.com (Bitcoin mainnet)</option>
<option value="digiexplorer.info"> DigiExplorer.info (DigiByte)</option>
<option value="chain.so_dogecoin"> Chain.so (Dogecoin)</option>
<option value="cryptoid.info_carboncoin"> Cryptoid.info (Carboncoin)</option>
</select>
Expand All @@ -1388,6 +1390,7 @@ <h2>Settings <small> making coinb.in even better!</small></h2>
<select class="form-control" id="coinjs_utxo">
<option value="coinb.in">coinb.in (Bitcoin mainnet)</option>
<option value="chain.so_litecoin"> Chain.so (Litecoin)</option>
<option value="digiexplorer.info"> DigiExplorer.info (DigiByte)</option>
<option value="chain.so_dogecoin"> Chain.so (Dogecoin)</option>
<option value="cryptoid.info_carboncoin"> Cryptoid.info (Carboncoin)</option>
</select>
Expand Down
67 changes: 67 additions & 0 deletions js/coinbin.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ $(document).ready(function() {

if(host=='chain.so_litecoin'){
listUnspentChainso_Litecoin(redeem);
} else if(host=='digiexplorer.info'){
listUnspentDigiExplorer(redeem);
} else if(host=='chain.so_dogecoin'){
listUnspentChainso_Dogecoin(redeem);
} else if(host=='cryptoid.info_carboncoin'){
Expand Down Expand Up @@ -1049,6 +1051,38 @@ $(document).ready(function() {

}

/* retrieve unspent data from digiexplorer.info for digibyte */
function listUnspentDigiExplorer(redeem){
$.ajax ({
type: "GET",
url: "https://digiexplorer.info/api/addr/"+redeem.addr+"/utxo",
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 && data.length){
$("#redeemFromAddress").removeClass('hidden').html(
'<span class="glyphicon glyphicon-info-sign"></span> Retrieved unspent inputs from address <a href="'+explorer_addr+redeem.addr+'" target="_blank">'+redeem.addr+'</a>');
for(var i in data){
var o = data[i];
var tx = o.txid;
var n = o.vout;
var script = (redeem.isMultisig==true) ? $("#redeemFrom").val() : o.scriptPubKey;
var amount = o.amount;
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();
}
});
}

/* retrieve unspent data from chain.so for dogecoin */
function listUnspentChainso_Dogecoin(redeem){
$.ajax ({
Expand Down Expand Up @@ -1286,6 +1320,35 @@ $(document).ready(function() {
});
}

function rawSubmitDigiExplorer(thisbtn){
$(thisbtn).val('Please wait, loading...').attr('disabled',true);
$.ajax ({
type: "POST",
url: "https://digiexplorer.info/api/tx/send",
data: JSON.stringify({ "rawtx": $("#rawTransaction").val() }),
dataType : "json",
contentType: "application/json",
error: function(data) {
var obj = data.responseText;
var r = ' ';
r += (obj) ? ' '+obj : '';
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>');
},
success: function(data) {
if(data){
$("#rawTransactionStatus").addClass('alert-success').removeClass('alert-danger').removeClass("hidden").html(' Txid: ' + 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);
}
});
}




Expand Down Expand Up @@ -1778,6 +1841,10 @@ $(document).ready(function() {
$("#rawSubmitBtn").click(function(){
rawSubmitChainso_BitcoinMainnet(this);
});
} else if(host=="digiexplorer.info"){
$("#rawSubmitBtn").click(function(){
rawSubmitDigiExplorer(this);
});
} else if(host=="chain.so_dogecoin"){
$("#rawSubmitBtn").click(function(){
rawSubmitchainso_dogecoin(this);
Expand Down