aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/index.html55
-rw-r--r--src/js/index.js23
-rw-r--r--tests.js52
3 files changed, 107 insertions, 23 deletions
diff --git a/src/index.html b/src/index.html
index aab473c..e3eebd6 100644
--- a/src/index.html
+++ b/src/index.html
@@ -313,6 +313,36 @@
313 </div> 313 </div>
314 </div> 314 </div>
315 <div class="form-group"> 315 <div class="form-group">
316 <label class="col-sm-2 control-label">
317 </label>
318 <div class="col-sm-10">
319 <p data-translate>The account extendend keys can be used for importing to most BIP44 compatible wallets, such as mycelium or electrum.</p>
320 </div>
321 </div>
322 <div class="form-group">
323 <label for="account-xprv" class="col-sm-2 control-label">
324 <span data-translate>Account Extended Private Key</span>
325 </label>
326 <div class="col-sm-10">
327 <textarea id="account-xprv" type="text" class="account-xprv form-control" readonly data-show-qr></textarea>
328 </div>
329 </div>
330 <div class="form-group">
331 <label for="account-xpub" class="col-sm-2 control-label">
332 <span data-translate>Account Extended Public Key</span>
333 </label>
334 <div class="col-sm-10">
335 <textarea id="account-xpub" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
336 </div>
337 </div>
338 <div class="form-group">
339 <label class="col-sm-2 control-label">
340 </label>
341 <div class="col-sm-10">
342 <p data-translate>The BIP32 derivation path and extended keys are the basis for the derived addresses.</p>
343 </div>
344 </div>
345 <div class="form-group">
316 <label for="bip44-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label> 346 <label for="bip44-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label>
317 <div class="col-sm-10"> 347 <div class="col-sm-10">
318 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly"> 348 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
@@ -344,27 +374,6 @@
344 </label> 374 </label>
345 </div> 375 </div>
346 <div class="form-group"> 376 <div class="form-group">
347 <label for="mycelium-path" class="col-sm-2 control-label" data-translate>Mycelium Wallet</label>
348 <div class="col-sm-10">
349 <p class="form-control no-border" data-translate-html>
350 <code>m/44'/0'/0'</code> generates extended keys for import / export
351 </p>
352 <p class="form-control no-border" data-translate-html>
353 <code>m/44'/0'/1'</code> for the next account. Continue incrementing for more accounts (most use a single account).
354 </p>
355 <p class="form-control no-border" data-translate-html>
356 <code>m/44'/0'/0'/0</code> generates public addresses
357 </p>
358 <p class="form-control no-border" data-translate-html>
359 <code>m/44'/0'/0'/1</code> generates change addresses
360 </p>
361 <p class="form-control no-border" data-translate-html>
362 For more info see the
363 <a href="http://www.mycelium.com/" target="_blank">Mycelium Wallet homepage</a>
364 </p>
365 </div>
366 </div>
367 <div class="form-group">
368 <label for="core-path" class="col-sm-2 control-label" data-translate>Bitcoin Core</label> 377 <label for="core-path" class="col-sm-2 control-label" data-translate>Bitcoin Core</label>
369 <div class="col-sm-10"> 378 <div class="col-sm-10">
370 <p class="form-control no-border" data-translate-html> 379 <p class="form-control no-border" data-translate-html>
@@ -394,13 +403,13 @@
394 </div> 403 </div>
395 <form class="form-horizontal" role="form"> 404 <form class="form-horizontal" role="form">
396 <div class="form-group"> 405 <div class="form-group">
397 <label for="extended-priv-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Key</label> 406 <label for="extended-priv-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Private Key</label>
398 <div class="col-sm-10"> 407 <div class="col-sm-10">
399 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly" data-show-qr></textarea> 408 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly" data-show-qr></textarea>
400 </div> 409 </div>
401 </div> 410 </div>
402 <div class="form-group"> 411 <div class="form-group">
403 <label for="extended-pub-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Key (addresses only)</label> 412 <label for="extended-pub-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Public Key</label>
404 <div class="col-sm-10"> 413 <div class="col-sm-10">
405 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr></textarea> 414 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr></textarea>
406 </div> 415 </div>
diff --git a/src/js/index.js b/src/js/index.js
index 6367c01..748a2ba 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -51,6 +51,8 @@
51 DOM.bip44purpose = $("#bip44 .purpose"); 51 DOM.bip44purpose = $("#bip44 .purpose");
52 DOM.bip44coin = $("#bip44 .coin"); 52 DOM.bip44coin = $("#bip44 .coin");
53 DOM.bip44account = $("#bip44 .account"); 53 DOM.bip44account = $("#bip44 .account");
54 DOM.bip44accountXprv = $("#bip44 .account-xprv");
55 DOM.bip44accountXpub = $("#bip44 .account-xpub");
54 DOM.bip44change = $("#bip44 .change"); 56 DOM.bip44change = $("#bip44 .change");
55 DOM.generatedStrength = $(".generate-container .strength"); 57 DOM.generatedStrength = $(".generate-container .strength");
56 DOM.hardenedAddresses = $(".hardened-addresses"); 58 DOM.hardenedAddresses = $(".hardened-addresses");
@@ -239,6 +241,9 @@
239 return; 241 return;
240 } 242 }
241 bip32ExtendedKey = calcBip32ExtendedKey(derivationPath); 243 bip32ExtendedKey = calcBip32ExtendedKey(derivationPath);
244 if (bip44TabSelected()) {
245 displayBip44Info();
246 }
242 displayBip32Info(); 247 displayBip32Info();
243 hidePending(); 248 hidePending();
244 } 249 }
@@ -450,6 +455,24 @@
450 return false; 455 return false;
451 } 456 }
452 457
458 function displayBip44Info() {
459 // Get the derivation path for the account
460 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
461 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
462 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
463 var path = "m/";
464 path += purpose + "'/";
465 path += coin + "'/";
466 path += account + "'/";
467 // Calculate the account extended keys
468 var accountExtendedKey = calcBip32ExtendedKey(path);
469 var accountXprv = accountExtendedKey.toBase58();
470 var accountXpub = accountExtendedKey.toBase58(false);
471 // Display the extended keys
472 DOM.bip44accountXprv.val(accountXprv);
473 DOM.bip44accountXpub.val(accountXpub);
474 }
475
453 function displayBip32Info() { 476 function displayBip32Info() {
454 // Display the key 477 // Display the key
455 DOM.seed.val(seed); 478 DOM.seed.val(seed);
diff --git a/tests.js b/tests.js
index 10d13a3..d5a73f6 100644
--- a/tests.js
+++ b/tests.js
@@ -3086,6 +3086,58 @@ page.open(url, function(status) {
3086}); 3086});
3087}, 3087},
3088 3088
3089// BIP44 account extendend private key is shown
3090// github issue 37 - compatibility with electrum
3091function() {
3092page.open(url, function(status) {
3093 // set the phrase
3094 var expected = "xprv9yzrnt4zWVJUr1k2VxSPy9ettKz5PpeDMgaVG7UKedhqnw1tDkxP2UyYNhuNSumk2sLE5ctwKZs9vwjsq3e1vo9egCK6CzP87H2cVYXpfwQ";
3095 page.evaluate(function() {
3096 $(".phrase").val("abandon abandon ability");
3097 $(".phrase").trigger("input");
3098 });
3099 // check the BIP44 account extended private key
3100 waitForGenerate(function() {
3101 var actual = page.evaluate(function() {
3102 return $(".account-xprv").val();
3103 });
3104 if (actual != expected) {
3105 console.log("BIP44 account extended private key is incorrect");
3106 console.log("Expected: " + expected);
3107 console.log("Actual: " + actual);
3108 fail();
3109 }
3110 next();
3111 });
3112});
3113},
3114
3115// BIP44 account extendend public key is shown
3116// github issue 37 - compatibility with electrum
3117function() {
3118page.open(url, function(status) {
3119 // set the phrase
3120 var expected = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
3121 page.evaluate(function() {
3122 $(".phrase").val("abandon abandon ability");
3123 $(".phrase").trigger("input");
3124 });
3125 // check the BIP44 account extended public key
3126 waitForGenerate(function() {
3127 var actual = page.evaluate(function() {
3128 return $(".account-xpub").val();
3129 });
3130 if (actual != expected) {
3131 console.log("BIP44 account extended public key is incorrect");
3132 console.log("Expected: " + expected);
3133 console.log("Actual: " + actual);
3134 fail();
3135 }
3136 next();
3137 });
3138});
3139},
3140
3089 3141
3090// If you wish to add more tests, do so here... 3142// If you wish to add more tests, do so here...
3091 3143