mirror of
https://github.com/ok2/coinbin.git
synced 2026-05-10 02:25:21 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c8ee40a9a |
+16
-18
@@ -582,27 +582,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label>Seed (WIF)</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<input id="newHDseed" type="text" class="form-control" value="" readonly>
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<button class="deriveHDbtn btn btn-default" type="button"><span title="Derive from key" class="glyphicon glyphicon-chevron-right"></span></button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Address Options</h3>
|
<h3>Address Options</h3>
|
||||||
<p>You can use the advanced options below to generate different kinds of master addresses.</p>
|
<p>You can use the advanced options below to generate different kinds of master addresses.</p>
|
||||||
|
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label><input type="checkbox" id="newHDBrainwallet" class="checkbox-inline"> Custom Seed or Brain Wallet</label>
|
<label><input type="checkbox" id="newHDBrainwallet" class="checkbox-inline"> Custom Seed or Brain Wallet</label>
|
||||||
<div class="hidden" id="HDBrainwalletInput">
|
<input type="text" class="form-control hidden" id="HDBrainwallet">
|
||||||
<input type="text" class="form-control" id="HDBrainwallet">
|
|
||||||
<span class="text-muted">
|
|
||||||
Number of HMAC SHA-256 iterations for seed generation, higher value mean's also longer calculation
|
|
||||||
(use value 0 to calculate just SHA-256, like in previous coinb.in versions):
|
|
||||||
<input type="text" class="form-control" id="HDBrainwalletIters" value="50000" size="10">
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="button" class="btn btn-primary" value="Generate" id="newHDKeysBtn">
|
<input type="button" class="btn btn-primary" value="Generate" id="newHDKeysBtn">
|
||||||
@@ -1208,14 +1193,14 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<b>Path</b><br>
|
<b>Path</b><br>
|
||||||
<select class="form-control" id="hdpathtype"">
|
<select class="form-control" id="hdpathtype">
|
||||||
<option value="simple">Simple: m/i</option>
|
<option value="simple">Simple: m/i</option>
|
||||||
<option value="custom">Custom</option>
|
<option value="custom">Custom</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div id="hdpath" class="hidden" style="margin-top:4px">
|
<div id="hdpath" class="hidden" style="margin-top:4px">
|
||||||
<span class="input-group">
|
<span class="input-group">
|
||||||
<input type="text" class="form-control" value="m/0/1"> <br>
|
<input type="text" class="form-control" value="m/0/1" title="WARNING: see #settings page when using hardened paths!"> <br>
|
||||||
<span class="input-group-addon"> / </span>
|
<span class="input-group-addon"> / </span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -1471,6 +1456,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<b>HD wallet hardened path derivation</b>: <br>
|
||||||
|
<p class="text-muted">The path derivation for hardened paths was calculated wrong in earlier versions of coinb.in. Please select the old path derivation to recover HD wallet keys generated with older version of coinb.in.</p>
|
||||||
|
<select class="form-control" id="coinjs_derivation">
|
||||||
|
<option value="bip32_derivation">BIP32 compliant derivation</option>
|
||||||
|
<option value="coinbin_broken">Old (broken) coinb.in path derivation</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div id="statusSettings" class="hidden alert">
|
<div id="statusSettings" class="hidden alert">
|
||||||
|
|||||||
+8
-21
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
coinjs.compressed = false;
|
coinjs.compressed = false;
|
||||||
|
|
||||||
|
coinjs.hd_derivation = "bip32_derivation";
|
||||||
|
|
||||||
/* other vars */
|
/* other vars */
|
||||||
coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin
|
coinjs.developer = '33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G'; //bitcoin
|
||||||
|
|
||||||
@@ -608,7 +610,6 @@
|
|||||||
r.parent_fingerprint = bytes.slice(5, 9);
|
r.parent_fingerprint = bytes.slice(5, 9);
|
||||||
r.child_index = coinjs.uint(bytes.slice(9, 13), 4);
|
r.child_index = coinjs.uint(bytes.slice(9, 13), 4);
|
||||||
r.chain_code = bytes.slice(13, 45);
|
r.chain_code = bytes.slice(13, 45);
|
||||||
r.seed_wif = '';
|
|
||||||
r.key_bytes = bytes.slice(45, 78);
|
r.key_bytes = bytes.slice(45, 78);
|
||||||
|
|
||||||
var c = coinjs.compressed; // get current default
|
var c = coinjs.compressed; // get current default
|
||||||
@@ -686,7 +687,11 @@
|
|||||||
r.derive = function(i){
|
r.derive = function(i){
|
||||||
|
|
||||||
i = (i)?i:0;
|
i = (i)?i:0;
|
||||||
|
if ((i >= 0x80000000) && (coinjs.hd_derivation == "bip32_derivation")) {
|
||||||
|
var blob = (Crypto.util.hexToBytes("00").concat(Crypto.util.hexToBytes(this.keys.privkey)).concat(coinjs.numToBytes(i,4).reverse()));
|
||||||
|
} else {
|
||||||
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
var blob = (Crypto.util.hexToBytes(this.keys.pubkey)).concat(coinjs.numToBytes(i,4).reverse());
|
||||||
|
}
|
||||||
|
|
||||||
var j = new jsSHA(Crypto.util.bytesToHex(blob), 'HEX');
|
var j = new jsSHA(Crypto.util.bytesToHex(blob), 'HEX');
|
||||||
var hash = j.getHMAC(Crypto.util.bytesToHex(r.chain_code), "HEX", "SHA-512", "HEX");
|
var hash = j.getHMAC(Crypto.util.bytesToHex(r.chain_code), "HEX", "SHA-512", "HEX");
|
||||||
@@ -743,23 +748,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make a master hd xprv/xpub
|
// make a master hd xprv/xpub
|
||||||
r.master = function(pass, iters) {
|
r.master = function(pass) {
|
||||||
if (pass) {
|
var seed = (pass) ? Crypto.SHA256(pass) : coinjs.newPrivkey();
|
||||||
var seed_iters = (iters) ? Math.abs(iters * 1) : 0;
|
|
||||||
if (seed_iters == 0) {
|
|
||||||
var seed = Crypto.SHA256(pass);
|
|
||||||
} else {
|
|
||||||
var seed = Crypto.util.hexToBytes("0000000000000000000000000000000000000000000000000000000000000000");
|
|
||||||
for (var i = 0; i < seed_iters; i++) {
|
|
||||||
seed = Crypto.HMAC(Crypto.SHA256, seed, pass, { asBytes: true });
|
|
||||||
}
|
|
||||||
seed = Crypto.util.bytesToHex(seed);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var seed = coinjs.newPrivkey();
|
|
||||||
}
|
|
||||||
|
|
||||||
var seed_wif = coinjs.privkey2wif(seed);
|
|
||||||
var hasher = new jsSHA(seed, 'HEX');
|
var hasher = new jsSHA(seed, 'HEX');
|
||||||
var I = hasher.getHMAC("Bitcoin seed", "TEXT", "SHA-512", "HEX");
|
var I = hasher.getHMAC("Bitcoin seed", "TEXT", "SHA-512", "HEX");
|
||||||
|
|
||||||
@@ -771,7 +761,6 @@
|
|||||||
'parent_fingerprint':[0,0,0,0],
|
'parent_fingerprint':[0,0,0,0],
|
||||||
'child_index':0,
|
'child_index':0,
|
||||||
'chain_code':chain,
|
'chain_code':chain,
|
||||||
'seed_wif':seed_wif,
|
|
||||||
'privkey':I.slice(0, 64),
|
'privkey':I.slice(0, 64),
|
||||||
'pubkey':coinjs.newPubkey(I.slice(0, 64))});
|
'pubkey':coinjs.newPubkey(I.slice(0, 64))});
|
||||||
}
|
}
|
||||||
@@ -816,8 +805,6 @@
|
|||||||
var ret = pub.concat(checksum);
|
var ret = pub.concat(checksum);
|
||||||
o.pubkey = coinjs.base58encode(ret);
|
o.pubkey = coinjs.base58encode(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
o.seed_wif = data.seed_wif;
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-9
@@ -570,20 +570,18 @@ $(document).ready(function() {
|
|||||||
$("#newHDKeysBtn").click(function(){
|
$("#newHDKeysBtn").click(function(){
|
||||||
coinjs.compressed = true;
|
coinjs.compressed = true;
|
||||||
var s = ($("#newHDBrainwallet").is(":checked")) ? $("#HDBrainwallet").val() : null;
|
var s = ($("#newHDBrainwallet").is(":checked")) ? $("#HDBrainwallet").val() : null;
|
||||||
var siters = ($("#newHDBrainwallet").is(":checked")) ? $("#HDBrainwalletIters").val()*1 : null;
|
|
||||||
var hd = coinjs.hd();
|
var hd = coinjs.hd();
|
||||||
var pair = hd.master(s, siters);
|
var pair = hd.master(s);
|
||||||
$("#newHDxpub").val(pair.pubkey);
|
$("#newHDxpub").val(pair.pubkey);
|
||||||
$("#newHDxprv").val(pair.privkey);
|
$("#newHDxprv").val(pair.privkey);
|
||||||
$("#newHDseed").val(pair.seed_wif);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#newHDBrainwallet").click(function(){
|
$("#newHDBrainwallet").click(function(){
|
||||||
if($(this).is(":checked")){
|
if($(this).is(":checked")){
|
||||||
$("#HDBrainwalletInput").removeClass("hidden");
|
$("#HDBrainwallet").removeClass("hidden");
|
||||||
} else {
|
} else {
|
||||||
$("#HDBrainwalletInput").addClass("hidden");
|
$("#HDBrainwallet").addClass("hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1683,7 +1681,6 @@ $(document).ready(function() {
|
|||||||
if(hex == hex_cmp_prv || hex == hex_cmp_pub){
|
if(hex == hex_cmp_prv || hex == hex_cmp_pub){
|
||||||
var hd = coinjs.hd(s);
|
var hd = coinjs.hd(s);
|
||||||
$("#verifyHDaddress .hdKey").html(s);
|
$("#verifyHDaddress .hdKey").html(s);
|
||||||
$("#verifyHDaddress .seed_wif").val(hd.seed_wif);
|
|
||||||
$("#verifyHDaddress .chain_code").val(Crypto.util.bytesToHex(hd.chain_code));
|
$("#verifyHDaddress .chain_code").val(Crypto.util.bytesToHex(hd.chain_code));
|
||||||
$("#verifyHDaddress .depth").val(hd.depth);
|
$("#verifyHDaddress .depth").val(hd.depth);
|
||||||
$("#verifyHDaddress .version").val('0x'+(hd.version).toString(16));
|
$("#verifyHDaddress .version").val('0x'+(hd.version).toString(16));
|
||||||
@@ -1704,15 +1701,23 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
function deriveHDaddress() {
|
function deriveHDaddress() {
|
||||||
var hd = coinjs.hd($("#verifyHDaddress .hdKey").html());
|
var hd = coinjs.hd($("#verifyHDaddress .hdKey").html());
|
||||||
var index_start = $("#verifyHDaddress .derivation_index_start").val()*1;
|
var index_start = $("#verifyHDaddress .derivation_index_start").val();
|
||||||
var index_end = $("#verifyHDaddress .derivation_index_end").val()*1;
|
if ((index_start.length > 1) && (index_start[index_start.length - 1] == '\'')) {
|
||||||
|
var use_private_index = '\'';
|
||||||
|
index_start = index_start.replace(/[']/, "") * 1;
|
||||||
|
} else {
|
||||||
|
var use_private_index = '';
|
||||||
|
index_start = index_start.replace(/[']/, "") * 1;
|
||||||
|
}
|
||||||
|
var index_end = $("#verifyHDaddress .derivation_index_end").val().replace(/[']/, "") * 1;
|
||||||
|
$("#verifyHDaddress .derivation_index_end").val(index_end + use_private_index);
|
||||||
var html = '';
|
var html = '';
|
||||||
$("#verifyHDaddress .derived_data table tbody").html("");
|
$("#verifyHDaddress .derived_data table tbody").html("");
|
||||||
for(var i=index_start;i<=index_end;i++){
|
for(var i=index_start;i<=index_end;i++){
|
||||||
if($("#hdpathtype option:selected").val()=='simple'){
|
if($("#hdpathtype option:selected").val()=='simple'){
|
||||||
var derived = hd.derive(i);
|
var derived = hd.derive(i);
|
||||||
} else {
|
} else {
|
||||||
var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i);
|
var derived = hd.derive_path(($("#hdpath input").val().replace(/\/+$/, ""))+'/'+i+use_private_index);
|
||||||
}
|
}
|
||||||
html += '<tr>';
|
html += '<tr>';
|
||||||
html += '<td>'+i+'</td>';
|
html += '<td>'+i+'</td>';
|
||||||
@@ -1917,6 +1922,8 @@ $(document).ready(function() {
|
|||||||
coinjs.hdkey.pub = $("#coinjs_hdpub").val()*1;
|
coinjs.hdkey.pub = $("#coinjs_hdpub").val()*1;
|
||||||
coinjs.hdkey.prv = $("#coinjs_hdprv").val()*1;
|
coinjs.hdkey.prv = $("#coinjs_hdprv").val()*1;
|
||||||
|
|
||||||
|
coinjs.hd_derivation = $("#coinjs_derivation").val();
|
||||||
|
|
||||||
configureBroadcast();
|
configureBroadcast();
|
||||||
configureGetUnspentTx();
|
configureGetUnspentTx();
|
||||||
|
|
||||||
@@ -1962,6 +1969,7 @@ $(document).ready(function() {
|
|||||||
$("#coinjs_multisig").val(o[2]);
|
$("#coinjs_multisig").val(o[2]);
|
||||||
$("#coinjs_hdpub").val(o[3]);
|
$("#coinjs_hdpub").val(o[3]);
|
||||||
$("#coinjs_hdprv").val(o[4]);
|
$("#coinjs_hdprv").val(o[4]);
|
||||||
|
$("#coinjs_derivation").val(o[7]);
|
||||||
|
|
||||||
// hide/show custom screen
|
// hide/show custom screen
|
||||||
if($("option:selected",this).val()=="custom"){
|
if($("option:selected",this).val()=="custom"){
|
||||||
|
|||||||
Reference in New Issue
Block a user