aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Coleman <ian@iancoleman.io>2018-01-03 09:32:14 +1100
committerIan Coleman <ian@iancoleman.io>2018-01-03 09:32:14 +1100
commit4e9b492ca4e1f90b985cfc2da94bddc60a36e386 (patch)
treef958a22a83df0ffd7fbae117f1ef444b487c1296 /src
parent91eb2cbcfd404e088a36d1ef03f4b174ee640ec7 (diff)
downloadBIP39-4e9b492ca4e1f90b985cfc2da94bddc60a36e386.tar.gz
BIP39-4e9b492ca4e1f90b985cfc2da94bddc60a36e386.tar.zst
BIP39-4e9b492ca4e1f90b985cfc2da94bddc60a36e386.zip
Add BIP84 tab
Diffstat (limited to 'src')
-rw-r--r--src/index.html83
-rw-r--r--src/js/index.js56
2 files changed, 137 insertions, 2 deletions
diff --git a/src/index.html b/src/index.html
index 8d8f756..0d1a2c6 100644
--- a/src/index.html
+++ b/src/index.html
@@ -204,6 +204,9 @@
204 <li id="bip49-tab"> 204 <li id="bip49-tab">
205 <a href="#bip49" role="tab" data-toggle="tab">BIP49</a> 205 <a href="#bip49" role="tab" data-toggle="tab">BIP49</a>
206 </li> 206 </li>
207 <li id="bip84-tab">
208 <a href="#bip84" role="tab" data-toggle="tab">BIP84</a>
209 </li>
207 <li id="bip141-tab"> 210 <li id="bip141-tab">
208 <a href="#bip141" role="tab" data-toggle="tab">BIP141</a> 211 <a href="#bip141" role="tab" data-toggle="tab">BIP141</a>
209 </li> 212 </li>
@@ -487,6 +490,86 @@
487 </div> 490 </div>
488 </form> 491 </form>
489 </div> 492 </div>
493 <div id="bip84" class="tab-pane">
494 <form class="form-horizontal" role="form">
495 <br>
496 <div class="col-sm-2"></div>
497 <div class="col-sm-10">
498 <p>
499 For more info see the
500 <a href="https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki" target="_blank">BIP84 spec</a>.
501 </p>
502 </div>
503 <div class="form-group">
504 <label for="purpose" class="col-sm-2 control-label">
505 Purpose
506 </label>
507 <div class="col-sm-10">
508 <input id="purpose" type="text" class="purpose form-control" value="84" readonly>
509 </div>
510 </div>
511 <div class="form-group">
512 <label for="coin" class="col-sm-2 control-label">
513 Coin
514 </label>
515 <div class="col-sm-10">
516 <input id="coin" type="text" class="coin form-control" value="0" readonly>
517 </div>
518 </div>
519 <div class="form-group">
520 <label for="account" class="col-sm-2 control-label">
521 Account
522 </label>
523 <div class="col-sm-10">
524 <input id="account" type="text" class="account form-control" value="0">
525 </div>
526 </div>
527 <div class="form-group">
528 <label for="change" class="col-sm-2 control-label">
529 External / Internal
530 </label>
531 <div class="col-sm-10">
532 <input id="change" type="text" class="change form-control" value="0">
533 </div>
534 </div>
535 <div class="form-group">
536 <label class="col-sm-2 control-label">
537 </label>
538 <div class="col-sm-10">
539 <p>The account extended keys can be used for importing to most BIP84 compatible wallets.</p>
540 </div>
541 </div>
542 <div class="form-group">
543 <label for="account-xprv" class="col-sm-2 control-label">
544 <span>Account Extended Private Key</span>
545 </label>
546 <div class="col-sm-10">
547 <textarea id="account-xprv" type="text" class="account-xprv form-control" readonly data-show-qr></textarea>
548 </div>
549 </div>
550 <div class="form-group">
551 <label for="account-xpub" class="col-sm-2 control-label">
552 <span>Account Extended Public Key</span>
553 </label>
554 <div class="col-sm-10">
555 <textarea id="account-xpub" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
556 </div>
557 </div>
558 <div class="form-group">
559 <label class="col-sm-2 control-label">
560 </label>
561 <div class="col-sm-10">
562 <p>The BIP32 derivation path and extended keys are the basis for the derived addresses.</p>
563 </div>
564 </div>
565 <div class="form-group">
566 <label for="bip84-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
567 <div class="col-sm-10">
568 <input id="bip84-path" type="text" class="path form-control" value="m/84'/0'/0'/0" readonly="readonly">
569 </div>
570 </div>
571 </form>
572 </div>
490 </div> 573 </div>
491 <form class="form-horizontal" role="form"> 574 <form class="form-horizontal" role="form">
492 <div class="form-group"> 575 <div class="form-group">
diff --git a/src/js/index.js b/src/js/index.js
index 9c9ad58..e63c65f 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -53,6 +53,7 @@
53 DOM.bip32tab = $("#bip32-tab"); 53 DOM.bip32tab = $("#bip32-tab");
54 DOM.bip44tab = $("#bip44-tab"); 54 DOM.bip44tab = $("#bip44-tab");
55 DOM.bip49tab = $("#bip49-tab"); 55 DOM.bip49tab = $("#bip49-tab");
56 DOM.bip84tab = $("#bip84-tab");
56 DOM.bip141tab = $("#bip141-tab"); 57 DOM.bip141tab = $("#bip141-tab");
57 DOM.bip32panel = $("#bip32"); 58 DOM.bip32panel = $("#bip32");
58 DOM.bip44panel = $("#bip44"); 59 DOM.bip44panel = $("#bip44");
@@ -74,6 +75,13 @@
74 DOM.bip49accountXprv = $("#bip49 .account-xprv"); 75 DOM.bip49accountXprv = $("#bip49 .account-xprv");
75 DOM.bip49accountXpub = $("#bip49 .account-xpub"); 76 DOM.bip49accountXpub = $("#bip49 .account-xpub");
76 DOM.bip49change = $("#bip49 .change"); 77 DOM.bip49change = $("#bip49 .change");
78 DOM.bip84path = $("#bip84-path");
79 DOM.bip84purpose = $("#bip84 .purpose");
80 DOM.bip84coin = $("#bip84 .coin");
81 DOM.bip84account = $("#bip84 .account");
82 DOM.bip84accountXprv = $("#bip84 .account-xprv");
83 DOM.bip84accountXpub = $("#bip84 .account-xpub");
84 DOM.bip84change = $("#bip84 .change");
77 DOM.bip141unavailable = $("#bip141 .unavailable"); 85 DOM.bip141unavailable = $("#bip141 .unavailable");
78 DOM.bip141available = $("#bip141 .available"); 86 DOM.bip141available = $("#bip141 .available");
79 DOM.bip141path = $("#bip141-path"); 87 DOM.bip141path = $("#bip141-path");
@@ -117,6 +125,8 @@
117 DOM.bip44change.on("input", calcForDerivationPath); 125 DOM.bip44change.on("input", calcForDerivationPath);
118 DOM.bip49account.on("input", calcForDerivationPath); 126 DOM.bip49account.on("input", calcForDerivationPath);
119 DOM.bip49change.on("input", calcForDerivationPath); 127 DOM.bip49change.on("input", calcForDerivationPath);
128 DOM.bip84account.on("input", calcForDerivationPath);
129 DOM.bip84change.on("input", calcForDerivationPath);
120 DOM.bip141path.on("input", calcForDerivationPath); 130 DOM.bip141path.on("input", calcForDerivationPath);
121 DOM.bip141semantics.on("change", tabChanged); 131 DOM.bip141semantics.on("change", tabChanged);
122 DOM.tab.on("shown.bs.tab", tabChanged); 132 DOM.tab.on("shown.bs.tab", tabChanged);
@@ -357,6 +367,9 @@
357 else if (bip49TabSelected()) { 367 else if (bip49TabSelected()) {
358 displayBip49Info(); 368 displayBip49Info();
359 } 369 }
370 else if (bip84TabSelected()) {
371 displayBip84Info();
372 }
360 displayBip32Info(); 373 displayBip32Info();
361 } 374 }
362 375
@@ -559,6 +572,21 @@
559 console.log("Using derivation path from BIP49 tab: " + derivationPath); 572 console.log("Using derivation path from BIP49 tab: " + derivationPath);
560 return derivationPath; 573 return derivationPath;
561 } 574 }
575 else if (bip84TabSelected()) {
576 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
577 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
578 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
579 var change = parseIntNoNaN(DOM.bip84change.val(), 0);
580 var path = "m/";
581 path += purpose + "'/";
582 path += coin + "'/";
583 path += account + "'/";
584 path += change;
585 DOM.bip84path.val(path);
586 var derivationPath = DOM.bip84path.val();
587 console.log("Using derivation path from BIP84 tab: " + derivationPath);
588 return derivationPath;
589 }
562 else if (bip32TabSelected()) { 590 else if (bip32TabSelected()) {
563 var derivationPath = DOM.bip32path.val(); 591 var derivationPath = DOM.bip32path.val();
564 console.log("Using derivation path from BIP32 tab: " + derivationPath); 592 console.log("Using derivation path from BIP32 tab: " + derivationPath);
@@ -659,6 +687,24 @@
659 DOM.bip49accountXpub.val(accountXpub); 687 DOM.bip49accountXpub.val(accountXpub);
660 } 688 }
661 689
690 function displayBip84Info() {
691 // Get the derivation path for the account
692 var purpose = parseIntNoNaN(DOM.bip84purpose.val(), 84);
693 var coin = parseIntNoNaN(DOM.bip84coin.val(), 0);
694 var account = parseIntNoNaN(DOM.bip84account.val(), 0);
695 var path = "m/";
696 path += purpose + "'/";
697 path += coin + "'/";
698 path += account + "'/";
699 // Calculate the account extended keys
700 var accountExtendedKey = calcBip32ExtendedKey(path);
701 var accountXprv = accountExtendedKey.toBase58();
702 var accountXpub = accountExtendedKey.neutered().toBase58();
703 // Display the extended keys
704 DOM.bip84accountXprv.val(accountXprv);
705 DOM.bip84accountXpub.val(accountXpub);
706 }
707
662 function displayBip32Info() { 708 function displayBip32Info() {
663 // Display the key 709 // Display the key
664 DOM.seed.val(seed); 710 DOM.seed.val(seed);
@@ -699,11 +745,12 @@
699 } 745 }
700 746
701 function segwitSelected() { 747 function segwitSelected() {
702 return bip49TabSelected() || bip141TabSelected(); 748 return bip49TabSelected() || bip84TabSelected() || bip141TabSelected();
703 } 749 }
704 750
705 function p2wpkhSelected() { 751 function p2wpkhSelected() {
706 return bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh"; 752 return bip84TabSelected() ||
753 bip141TabSelected() && DOM.bip141semantics.val() == "p2wpkh";
707 } 754 }
708 755
709 function p2wpkhInP2shSelected() { 756 function p2wpkhInP2shSelected() {
@@ -1284,6 +1331,10 @@
1284 return DOM.bip49tab.hasClass("active"); 1331 return DOM.bip49tab.hasClass("active");
1285 } 1332 }
1286 1333
1334 function bip84TabSelected() {
1335 return DOM.bip84tab.hasClass("active");
1336 }
1337
1287 function bip141TabSelected() { 1338 function bip141TabSelected() {
1288 return DOM.bip141tab.hasClass("active"); 1339 return DOM.bip141tab.hasClass("active");
1289 } 1340 }
@@ -1291,6 +1342,7 @@
1291 function setHdCoin(coinValue) { 1342 function setHdCoin(coinValue) {
1292 DOM.bip44coin.val(coinValue); 1343 DOM.bip44coin.val(coinValue);
1293 DOM.bip49coin.val(coinValue); 1344 DOM.bip49coin.val(coinValue);
1345 DOM.bip84coin.val(coinValue);
1294 } 1346 }
1295 1347
1296 function showSegwitAvailable() { 1348 function showSegwitAvailable() {