]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Remove segwit from bip32 tab
authorIan Coleman <ian@iancoleman.io>
Tue, 21 Nov 2017 22:59:58 +0000 (09:59 +1100)
committerIan Coleman <ian@iancoleman.io>
Tue, 21 Nov 2017 22:59:58 +0000 (09:59 +1100)
This option will be added in the future to a bip141 tab

src/index.html
src/js/index.js
tests/spec/tests.js

index 9c126b976201d58cd2ed5b2a724f361ef824ade8..b638b2623d860c9808337e67dfa5fffa5121a0c8 100644 (file)
                                         <span>Use hardened addresses</span>
                                     </label>
                                 </div>
-                                <div class="form-group">
-                                    <div class="col-sm-2"></div>
-                                    <label class="col-sm-10">
-                                        <input class="p2wpkh-nested-in-p2sh" type="checkbox">
-                                        <span>Use SegWit addresses (ie P2WPKH Nested In P2SH)</span>
-                                    </label>
-                                </div>
                                 <div class="form-group">
                                     <label for="core-path" class="col-sm-2 control-label">Bitcoin Core</label>
                                     <div class="col-sm-10">
index e4920ce1242fa9b1d928341d904c32e039f16fc0..b88e9d730704aa85114af5736b0c287771cb7a88 100644 (file)
@@ -74,7 +74,6 @@
     DOM.bip49change = $("#bip49 .change");
     DOM.generatedStrength = $(".generate-container .strength");
     DOM.hardenedAddresses = $(".hardened-addresses");
-    DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
     DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container");
     DOM.useBitpayAddresses = $(".use-bitpay-addresses");
     DOM.addresses = $(".addresses");
         DOM.bip49change.on("input", calcForDerivationPath);
         DOM.tab.on("shown.bs.tab", tabChanged);
         DOM.hardenedAddresses.on("change", calcForDerivationPath);
-        DOM.useP2wpkhNestedInP2sh.on("change", calcForDerivationPath);
         DOM.indexToggle.on("click", toggleIndexes);
         DOM.addressToggle.on("click", toggleAddresses);
         DOM.publicKeyToggle.on("click", togglePublicKeys);
         var networkIndex = e.target.value;
         var network = networks[networkIndex];
         network.onSelect();
-        if (network.p2wpkhNestedInP2shAvailable) {
-            showP2wpkhNestedInP2shAvailable();
+        if (network.segwitAvailable) {
+            showSegwitAvailable();
         }
         else {
-            showP2wpkhNestedInP2shUnavailable();
+            showSegwitUnavailable();
         }
         if (seed != null) {
             phraseChanged();
 
     function tabChanged() {
         showPending();
-        adjustNetworkForBip49();
+        adjustNetworkForSegwit();
         var phrase = DOM.phrase.val();
         if (phrase != "") {
             // Calculate and display for mnemonic
         clearDerivedKeys();
         clearAddressesList();
         showPending();
-        // Don't show bip49 if it's selected but network doesn't support it
-        if (bip49TabSelected() && !networkHasBip49()) {
+        // Don't show segwit if it's selected but network doesn't support it
+        if (segwitSelected() && !networkHasSegwit()) {
             return;
         }
         // Get the derivation path
         })());
     }
 
-    function P2wpkhNestedInP2shSelected() {
-        return bip49TabSelected() || (bip32TabSelected() && useP2wpkhNestedInP2sh());
+    function segwitSelected() {
+        return bip49TabSelected();
     }
 
     function TableRow(index, isLast) {
         var self = this;
         this.shouldGenerate = true;
         var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
-        var isP2wpkhNestedInP2sh = P2wpkhNestedInP2shSelected();
-        var p2wpkhNestedInP2shAvailable = networkHasBip49();
+        var isSegwit = segwitSelected();
+        var segwitAvailable = networkHasSegwit();
 
         function init() {
             calculateValues();
                     privkey = convertRipplePriv(privkey);
                     address = convertRippleAdrr(address);
                 }
-                // BIP49 addresses are different
-                if (isP2wpkhNestedInP2sh) {
-                    if (!p2wpkhNestedInP2shAvailable) {
+                // Segwit addresses are different
+                if (isSegwit) {
+                    if (!segwitAvailable) {
                         return;
                     }
                     var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
         return DOM.bip32tab.hasClass("active");
     }
 
-    function useP2wpkhNestedInP2sh() {
-        return DOM.useP2wpkhNestedInP2sh.prop("checked");
-    }
-
-    function networkHasBip49() {
-        return networks[DOM.network.val()].p2wpkhNestedInP2shAvailable;
+    function networkHasSegwit() {
+        return networks[DOM.network.val()].segwitAvailable;
     }
 
     function bip49TabSelected() {
         DOM.bip49coin.val(coinValue);
     }
 
-    function showP2wpkhNestedInP2shAvailable() {
+    function showSegwitAvailable() {
         DOM.bip49unavailable.addClass("hidden");
         DOM.bip49available.removeClass("hidden");
-        DOM.useP2wpkhNestedInP2sh.prop("disabled", false);
     }
 
-    function showP2wpkhNestedInP2shUnavailable() {
+    function showSegwitUnavailable() {
         DOM.bip49available.addClass("hidden");
         DOM.bip49unavailable.removeClass("hidden");
-        DOM.useP2wpkhNestedInP2sh.prop("disabled", true);
-        DOM.useP2wpkhNestedInP2sh.prop("checked", false);
     }
 
     function useBitpayAddresses() {
         }
     }
 
-    function adjustNetworkForBip49() {
-        // If bip49 is selected the xpub/xprv prefixes need to be adjusted
+    function adjustNetworkForSegwit() {
+        // If segwit is selected the xpub/xprv prefixes need to be adjusted
         // to avoid accidentally importing BIP49 xpub to BIP44 watch only
         // wallet.
         // See https://github.com/iancoleman/bip39/issues/125
-        if (P2wpkhNestedInP2shSelected()) {
+        if (segwitSelected()) {
             if (network == bitcoinjs.bitcoin.networks.bitcoin) {
                 network = bitcoinjs.bitcoin.networks.bitcoinBip49;
             }
     var networks = [
         {
             name: "BCH - Bitcoin Cash",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 DOM.useBitpayAddressesContainer.removeClass("hidden");
                 setBitcoinCashNetworkValues();
         },
         {
             name: "BTC - Bitcoin",
-            p2wpkhNestedInP2shAvailable: true,
+            segwitAvailable: true,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.bitcoin;
                 setHdCoin(0);
         },
         {
             name: "BTC - Bitcoin Testnet",
-            p2wpkhNestedInP2shAvailable: true,
+            segwitAvailable: true,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.testnet;
                 setHdCoin(1);
         },
         {
             name: "BTG - Bitcoin Gold",
-            p2wpkhNestedInP2shAvailable: true,
+            segwitAvailable: true,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.bgold;
                 setHdCoin(0);
         },
         {
             name: "CLAM - Clams",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.clam;
                 setHdCoin(23);
         },
         {
             name: "CRW - Crown",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.crown;
                 setHdCoin(72);
         },
         {
             name: "DASH - Dash",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.dash;
                 setHdCoin(5);
         },
         {
             name: "DASH - Dash Testnet",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.dashtn;
                 setHdCoin(1);
         },
         {
             name: "DOGE - Dogecoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.dogecoin;
                 setHdCoin(3);
         },
         {
             name: "ETH - Ethereum",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.bitcoin;
                 setHdCoin(60);
         },
         {
             name: "FJC - Fujicoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.fujicoin;
                 setHdCoin(75);
         },
         {
             name: "GAME - GameCredits",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.game;
                 setHdCoin(101);
         },
         {
             name: "JBS - Jumbucks",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.jumbucks;
                 setHdCoin(26);
         },
         {
             name: "LTC - Litecoin",
-            p2wpkhNestedInP2shAvailable: true,
+            segwitAvailable: true,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.litecoin;
                 setHdCoin(2);
         },
         {
             name: "MAZA - Maza",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.maza;
                 setHdCoin(13);
         },
         {
             name: "MONA - Monacoin",
-            p2wpkhNestedInP2shAvailable: true,
+            segwitAvailable: true,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.monacoin,
                 setHdCoin(22);
         },
         {
             name: "NMC - Namecoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.namecoin;
                 setHdCoin(7);
         },
         {
             name: "PIVX - PIVX",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.pivx;
                 setHdCoin(119);
         },
         {
             name: "PIVX - PIVX Testnet",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.pivxtestnet;
                 setHdCoin(1);
         },
         {
             name: "PPC - Peercoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.peercoin;
                 setHdCoin(6);
         },
         {
             name: "SDC - ShadowCash",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.shadow;
                 setHdCoin(35);
         },
         {
             name: "SDC - ShadowCash Testnet",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.shadowtn;
                 setHdCoin(1);
         },
         {
             name: "SLM - Slimcoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.slimcoin;
                 setHdCoin(63);
         },
         {
             name: "SLM - Slimcoin Testnet",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.slimcointn;
                 setHdCoin(111);
         },
         {
             name: "USNBT - NuBits",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.nubits;
                 setHdCoin(12);
         },
         {
             name: "VIA - Viacoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.viacoin;
                 setHdCoin(14);
         },
         {
             name: "VIA - Viacoin Testnet",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.viacointestnet;
                 setHdCoin(1);
         },
         {
             name: "XMY - Myriadcoin",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.myriadcoin;
                 setHdCoin(90);
         },
         {
             name: "XRP - Ripple",
-            p2wpkhNestedInP2shAvailable: false,
+            segwitAvailable: false,
             onSelect: function() {
                 network = bitcoinjs.bitcoin.networks.bitcoin;
                 setHdCoin(144);
index 4f774e8d0693ee7b85165f5d6664185793ed4e18..f3ffbbfcdb3d0bdd2e6385c80d59a7d2bc7c4739 100644 (file)
@@ -2504,31 +2504,6 @@ it('Uses ltub by default for litecoin, but can be set to xprv', function(done) {
     });
 });
 
-// BIP32 tab can use P2WPKH Nested In P2SH
-// github issue 91 part 2
-// https://github.com/iancoleman/bip39/issues/91
-// generate new addresses from xpub?
-it('Uses xprv by default for litecoin, but can be set to ltpv', function(done) {
-    // use p2wpkh addresses
-    driver.executeScript(function() {
-        $(".p2wpkh-nested-in-p2sh").prop("checked", true);
-    });
-    // use bip32 tab
-    driver.findElement(By.css('#bip32-tab a'))
-        .click()
-    // use testnet
-    selectNetwork("BTC - Bitcoin Testnet");
-    // Set root xpub to BIP49 official test vector account 0
-    driver.findElement(By.css('.root-key'))
-        .sendKeys("tpubDD7tXK8KeQ3YY83yWq755fHY2JW8Ha8Q765tknUM5rSvjPcGWfUppDFMpQ1ScziKfW3ZNtZvAD7M3u7bSs7HofjTD3KP3YxPK7X6hwV8Rk2");
-    driver.sleep(generateDelay).then(function() {
-        getFirstAddress(function(address) {
-            expect(address).toBe("2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2");
-            done();
-        });
-    });
-});
-
 // github issue 99
 // https://github.com/iancoleman/bip39/issues/99#issuecomment-327094159
 // "warn me emphatically when they have detected invalid input" to the entropy field