segwit support added

This commit is contained in:
OutCast3k
2017-09-10 13:18:31 +00:00
parent d5fe5ea828
commit 6c480a1102
5 changed files with 384 additions and 72 deletions
+47 -3
View File
@@ -281,6 +281,14 @@ $(document).ready(function() {
}
});
$("#newSegWitBrainwallet").click(function(){
if($(this).is(":checked")){
$("#brainwalletSegWit").removeClass("hidden");
} else {
$("#brainwalletSegWit").addClass("hidden");
}
});
$("#encryptKey").click(function(){
if($(this).is(":checked")){
$("#aes256passform").removeClass("hidden");
@@ -289,6 +297,21 @@ $(document).ready(function() {
}
});
/* new -> segwit code */
$("#newSegWitKeysBtn").click(function(){
var compressed = coinjs.compressed;
coinjs.compressed = true;
var s = ($("#newSegWitBrainwallet").is(":checked")) ? $("#brainwalletSegWit").val() : null;
var coin = coinjs.newKeys(s);
var sw = coinjs.segwitAddress(coin.pubkey);
$("#newSegWitAddress").val(sw.address);
$("#newSegWitRedeemScript").val(sw.redeemscript);
$("#newSegWitPubKey").val(coin.pubkey);
$("#newSegWitPrivKey").val(coin.wif);
coinjs.compressed = compressed;
});
/* new -> multisig code */
$("#newMultiSigAddress").click(function(){
@@ -710,9 +733,9 @@ $(document).ready(function() {
listUnspentBlockrio_BitcoinMainnet(redeem);
} else if(host=='chain.so_litecoin'){
listUnspentChainso_Litecoin(redeem);
} else if(host=='chain.so_dogecoin'){
} else if(host=='chain.so_dogecoin'){
listUnspentChainso_Dogecoin(redeem);
} else if(host=='cryptoid.info_carboncoin'){
} else if(host=='cryptoid.info_carboncoin'){
listUnspentCryptoidinfo_Carboncoin(redeem);
} else {
listUnspentDefault(redeem);
@@ -810,6 +833,15 @@ $(document).ready(function() {
$("#inputs .txId:last").val(txid);
$("#inputs .txIdN:last").val(n);
$("#inputs .txIdAmount:last").val(amount);
if(script.match(/^00/) && script.length==44){
s = coinjs.script();
s.writeBytes(Crypto.util.hexToBytes(script));
s.writeOp(0);
s.writeBytes(coinjs.numToBytes((amount*100000000).toFixed(0), 8));
script = Crypto.util.bytesToHex(s.buffer);
}
$("#inputs .txIdScript:last").val(script);
}
}
@@ -1277,6 +1309,9 @@ $(document).ready(function() {
if(decode){
$("#verifyRsDataMultisig").addClass('hidden');
$("#verifyRsDataHodl").addClass('hidden');
$("#verifyRsDataSegWit").addClass('hidden');
$("#verifyRsData").addClass("hidden");
if(decode.type == "multisig__") {
$("#verifyRsDataMultisig .multisigAddress").val(decode['address']);
@@ -1291,6 +1326,11 @@ $(document).ready(function() {
$("#verifyRsDataMultisig").removeClass('hidden');
$(".verifyLink").attr('href','?verify='+$("#verifyScript").val());
return true;
} else if(decode.type == "segwit__"){
$("#verifyRsData").removeClass("hidden");
$("#verifyRsDataSegWit .segWitAddress").val(decode['address']);
$("#verifyRsDataSegWit").removeClass('hidden');
return true;
} else if(decode.type == "hodl__") {
var d = $("#verifyRsDataHodl .date").data("DateTimePicker");
$("#verifyRsDataHodl .address").val(decode['address']);
@@ -1314,6 +1354,10 @@ $(document).ready(function() {
$("#verifyTransactionData .transactionSize").html(decode.size()+' <i>bytes</i>');
$("#verifyTransactionData .transactionLockTime").html(decode['lock_time']);
$("#verifyTransactionData .transactionRBF").hide();
$("#verifyTransactionData .transactionSegWit").hide();
if (decode.witness.length>=1) {
$("#verifyTransactionData .transactionSegWit").show();
}
$("#verifyTransactionData").removeClass("hidden");
$("#verifyTransactionData tbody").html("");
@@ -1324,7 +1368,7 @@ $(document).ready(function() {
h += '<td><input class="form-control" type="text" value="'+o.outpoint.hash+'" readonly></td>';
h += '<td class="col-xs-1">'+o.outpoint.index+'</td>';
h += '<td class="col-xs-2"><input class="form-control" type="text" value="'+Crypto.util.bytesToHex(o.script.buffer)+'" readonly></td>';
h += '<td class="col-xs-1"> <span class="glyphicon glyphicon-'+((s.signed=='true')?'ok':'remove')+'-circle"></span>';
h += '<td class="col-xs-1"> <span class="glyphicon glyphicon-'+((s.signed=='true' || (decode.witness[i] && decode.witness[i].length==2))?'ok':'remove')+'-circle"></span>';
if(s['type']=='multisig' && s['signatures']>=1){
h += ' '+s['signatures'];
}