added segwit support to the wallet section of #coinb.in

This commit is contained in:
OutCast3k 2017-09-16 09:03:10 +00:00
parent 4afee020b0
commit 4a4f302fe6
4 changed files with 52 additions and 24 deletions

View file

@ -151,6 +151,15 @@
<input id="openPass" type="password" class="form-control" placeholder="Password" required>
<input id="openPassConfirm" type="password" class="form-control" placeholder="Password confirm" required>
<br>
<div>
<a href="javascript:;" class="optionsCollapse"><div class="well well-sm"><span class="glyphicon glyphicon-collapse-down" id="glyphcollapse"></span> Advanced Options</div></a>
<div class="hidden optionsAdvanced">
<label>Segregated Witness Address</label>
<p class="checkbox">
<label><input type="checkbox" id="walletSegwit" class="checkbox-inline"> Use a segwit address instead of a regular address.</label>
</p>
</div>
</div>
<div id="openLoginStatus" class="alert alert-danger hidden"></div>
<button id="openBtn" class="btn btn-primary" type="submit">Submit</button>
</form>
@ -557,9 +566,9 @@
<div class="hidden alert alert-info" id="redeemFromAddress"></div>
<div>
<a href="javascript:;" id="optionsCollapse"><div class="well well-sm"><span class="glyphicon glyphicon-collapse-down" id="glyphcollapse"></span> Advanced Options</div></a>
<a href="javascript:;" class="optionsCollapse"><div class="well well-sm"><span class="glyphicon glyphicon-collapse-down" id="glyphcollapse"></span> Advanced Options</div></a>
<div class="hidden" id="optionsAdvanced">
<div class="hidden optionsAdvanced">
<label>Clear Inputs</label>
<p class="checkbox">

View file

@ -876,7 +876,7 @@
}
/* add unspent to transaction */
r.addUnspent = function(address, callback){
r.addUnspent = function(address, callback, script){
var self = this;
this.listUnspent(address, function(data){
var s = coinjs.script();
@ -900,9 +900,9 @@
var u = xmlDoc.getElementsByTagName("unspent_"+i)[0]
var txhash = (u.getElementsByTagName("tx_hash")[0].childNodes[0].nodeValue).match(/.{1,2}/g).reverse().join("")+'';
var n = u.getElementsByTagName("tx_output_n")[0].childNodes[0].nodeValue;
var script = u.getElementsByTagName("script")[0].childNodes[0].nodeValue;
var scr = script || u.getElementsByTagName("script")[0].childNodes[0].nodeValue;
self.addinput(txhash, n, script);
self.addinput(txhash, n, scr);
value += u.getElementsByTagName("value")[0].childNodes[0].nodeValue*1;
total++;

View file

@ -28,17 +28,26 @@ $(document).ready(function() {
coinjs.compressed = true;
var keys = coinjs.newKeys(s);
var address = keys.address;
var wif = keys.wif;
var pubkey = keys.pubkey;
var privkeyaes = CryptoJS.AES.encrypt(keys.wif, pass);
$("#walletAddress").html(keys.address);
$("#walletHistory").attr('href',explorer_addr+keys.address);
if($("#walletSegwit").is(":checked")){
var sw = coinjs.segwitAddress(pubkey);
address = sw.address;
}
$("#walletAddress").html(address);
$("#walletHistory").attr('href',explorer_addr+address);
$("#walletQrCode").html("");
var qrcode = new QRCode("walletQrCode");
qrcode.makeCode("bitcoin:"+keys.address);
qrcode.makeCode("bitcoin:"+address);
$("#walletKeys .privkey").val(keys.wif);
$("#walletKeys .pubkey").val(keys.pubkey);
$("#walletKeys .privkeyaes").val(CryptoJS.AES.encrypt(keys.wif, pass));
$("#walletKeys .privkey").val(wif);
$("#walletKeys .pubkey").val(pubkey);
$("#walletKeys .privkeyaes").val(privkeyaes);
$("#openLogin").hide();
$("#openWallet").removeClass("hidden").show();
@ -76,6 +85,7 @@ $(document).ready(function() {
$("#walletKeys .privkey").val("");
$("#walletKeys .pubkey").val("");
$("#openLoginStatus").html("").hide();
});
$("#walletShowKeys").click(function(){
@ -111,6 +121,12 @@ $(document).ready(function() {
thisbtn.attr('disabled',true);
var script = false;
if($("#walletSegwit").is(":checked")){
var sw = coinjs.segwitAddress($("#walletKeys .pubkey").val());
scrip = sw.redeemscript;
}
tx.addUnspent($("#walletAddress").html(), function(data){
var dvalue = (data.value/100000000).toFixed(8) * 1;
@ -150,7 +166,8 @@ $(document).ready(function() {
}
$("#walletLoader").addClass("hidden");
});
}, script);
});
$("#walletSendBtn").click(function(){
@ -246,7 +263,9 @@ $(document).ready(function() {
function checkBalanceLoop(){
setTimeout(function(){
if($("#walletLoader").hasClass("hidden")){
walletBalance();
}
checkBalanceLoop();
},45000);
}
@ -1015,13 +1034,13 @@ $(document).ready(function() {
$("#transactionFee").val((fee>0)?fee:'0.00');
}
$("#optionsCollapse").click(function(){
if($("#optionsAdvanced").hasClass('hidden')){
$("#glyphcollapse").removeClass('glyphicon-collapse-down').addClass('glyphicon-collapse-up');
$("#optionsAdvanced").removeClass("hidden");
$(".optionsCollapse").click(function(){
if($(".optionsAdvanced",$(this).parent()).hasClass('hidden')){
$(".glyphcollapse",$(this).parent()).removeClass('glyphicon-collapse-down').addClass('glyphicon-collapse-up');
$(".optionsAdvanced",$(this).parent()).removeClass("hidden");
} else {
$("#glyphcollapse").removeClass('glyphicon-collapse-up').addClass('glyphicon-collapse-down');
$("#optionsAdvanced").addClass("hidden");
$(".glyphcollapse",$(this).parent()).removeClass('glyphicon-collapse-up').addClass('glyphicon-collapse-down');
$(".optionsAdvanced",$(this).parent()).addClass("hidden");
}
});

View file

@ -1,9 +1,9 @@
---- Version 1.3 2017.09.10 ----
---- Version 1.3 2017.09.16 ----
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js
253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js
7f515cda8dae2ba8217e4f9626d35f29a6c8933f ./js/coinbin.js
3e7b9b1a30412f827d4709a53014d0b6f06103f0 ./js/coin.js
618db47822494e730a8fa93cfab985332872b93e ./js/coinbin.js
b2b1b00455dd2d1f168dc68b6efdbb1de817b5d0 ./js/coin.js
988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
@ -30,4 +30,4 @@ de51a8494180a6db074af2dee2383f0a363c5b08 ./fonts/glyphicons-halflings-regular.s
278e49a86e634da6f2a02f3b47dd9d2a8f26210f ./fonts/glyphicons-halflings-regular.woff
44bc1850f570972267b169ae18f1cb06b611ffa2 ./fonts/glyphicons-halflings-regular.ttf
d8a324a13501cd5705dc26b945fc8088f00907ae ./README.md
384db7d004aedfdcb4ce2fdb93edb8fa6df9c075 ./index.html
cc101e4b9718116bb767f7cbd04cab816ca32b66 ./index.html