From bda303dd533def617087827183aa9129450d6cfa Mon Sep 17 00:00:00 2001 From: Loshan T Date: Wed, 16 May 2018 23:34:28 +0100 Subject: [PATCH 01/15] Add Litecoin bech32 HRP --- src/js/segwit-parameters.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/segwit-parameters.js b/src/js/segwit-parameters.js index f8b0347..2954b27 100644 --- a/src/js/segwit-parameters.js +++ b/src/js/segwit-parameters.js @@ -59,6 +59,7 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = { bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = { baseNetwork: "litecoin", messagePrefix: '\x19Litecoin Signed Message:\n', + bech32: 'ltc', bip32: { public: 0x01b26ef6, private: 0x01b26792 From 29c30bf33ae079c55007d8738d077d10d40bca2b Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 18 May 2018 10:26:54 -0400 Subject: [PATCH 02/15] Fix incorrect address generation for altcoins with bip38 --- src/js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 567a3f7..afa743d 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -813,7 +813,7 @@ var keyPair = key.keyPair; var useUncompressed = useBip38; if (useUncompressed) { - keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { compressed: false }); + keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false }); } // get address var address = keyPair.getAddress().toString(); @@ -821,7 +821,7 @@ var hasPrivkey = !key.isNeutered(); var privkey = "NA"; if (hasPrivkey) { - privkey = keyPair.toWIF(network); + privkey = keyPair.toWIF(); // BIP38 encode private key if required if (useBip38) { privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) { From 6df5b2a1004c99e82d33c4070a25ee94157301f8 Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 18 May 2018 10:31:46 -0400 Subject: [PATCH 03/15] increase maximum payload length for zcash --- src/js/bitcoinjs-3.3.2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/bitcoinjs-3.3.2.js b/src/js/bitcoinjs-3.3.2.js index 2390168..0a6c588 100644 --- a/src/js/bitcoinjs-3.3.2.js +++ b/src/js/bitcoinjs-3.3.2.js @@ -8642,7 +8642,7 @@ function fromBase58Check (address) { // TODO: 4.0.0, move to "toOutputScript" if (payload.length < 21) throw new TypeError(address + ' is too short') - if (payload.length > 21) throw new TypeError(address + ' is too long') + if (payload.length > 22) throw new TypeError(address + ' is too long') var version = payload.readUInt8(0) var hash = payload.slice(1) From 55b878d8d55639cea6d5cd0755194e0e768ba4de Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 21 May 2018 11:05:49 -0400 Subject: [PATCH 04/15] undo zcash max payload length fix --- src/js/bitcoinjs-3.3.2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/bitcoinjs-3.3.2.js b/src/js/bitcoinjs-3.3.2.js index 0a6c588..2390168 100644 --- a/src/js/bitcoinjs-3.3.2.js +++ b/src/js/bitcoinjs-3.3.2.js @@ -8642,7 +8642,7 @@ function fromBase58Check (address) { // TODO: 4.0.0, move to "toOutputScript" if (payload.length < 21) throw new TypeError(address + ' is too short') - if (payload.length > 22) throw new TypeError(address + ' is too long') + if (payload.length > 21) throw new TypeError(address + ' is too long') var version = payload.readUInt8(0) var hash = payload.slice(1) From 5c3143888e4beb26ca3d706088fa10376eaa1aa2 Mon Sep 17 00:00:00 2001 From: Viacheslav Bakshaev Date: Sat, 26 May 2018 12:52:30 +0200 Subject: [PATCH 05/15] Update index.html html: missed closing --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index a53a20b..916ec81 100644 --- a/src/index.html +++ b/src/index.html @@ -108,7 +108,7 @@ + -
- +
+
- +

+ For more info see the + BIP84 spec. +

-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
-

The account extended keys can be used for importing to most BIP84 compatible wallets.

+
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+

The account extended keys can be used for importing to most BIP84 compatible wallets.

+
-
-
- -
-

The BIP32 derivation path and extended keys are the basis for the derived addresses.

+
+ +
+ +
-
-
- -
- +
+ +
+ +
+
+
+ +
+

The BIP32 derivation path and extended keys are the basis for the derived addresses.

+
+
+
+ +
+ +
diff --git a/src/js/index.js b/src/js/index.js index afa743d..6cff8c4 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -77,6 +77,8 @@ DOM.bip49accountXprv = $("#bip49 .account-xprv"); DOM.bip49accountXpub = $("#bip49 .account-xpub"); DOM.bip49change = $("#bip49 .change"); + DOM.bip84unavailable = $("#bip84 .unavailable"); + DOM.bip84available = $("#bip84 .available"); DOM.bip84path = $("#bip84-path"); DOM.bip84purpose = $("#bip84 .purpose"); DOM.bip84coin = $("#bip84 .coin"); @@ -1415,6 +1417,8 @@ function showSegwitAvailable() { DOM.bip49unavailable.addClass("hidden"); DOM.bip49available.removeClass("hidden"); + DOM.bip84unavailable.addClass("hidden"); + DOM.bip84available.removeClass("hidden"); DOM.bip141unavailable.addClass("hidden"); DOM.bip141available.removeClass("hidden"); } @@ -1422,6 +1426,8 @@ function showSegwitUnavailable() { DOM.bip49available.addClass("hidden"); DOM.bip49unavailable.removeClass("hidden"); + DOM.bip84available.addClass("hidden"); + DOM.bip84unavailable.removeClass("hidden"); DOM.bip141available.addClass("hidden"); DOM.bip141unavailable.removeClass("hidden"); } From c147cb5e4f40297c2377ecb5b03975b3f04d75bd Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 08:48:34 +1000 Subject: [PATCH 07/15] Replace hasSegwit variable with test for params --- src/js/index.js | 141 ++++++------------------------------------------ 1 file changed, 17 insertions(+), 124 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 6cff8c4..c9bbdc6 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -178,13 +178,7 @@ var networkIndex = e.target.value; var network = networks[networkIndex]; network.onSelect(); - if (network.segwitAvailable) { - adjustNetworkForSegwit(); - showSegwitAvailable(); - } - else { - showSegwitUnavailable(); - } + adjustNetworkForSegwit(); if (seed != null) { phraseChanged(); } @@ -374,8 +368,10 @@ showPending(); // Don't show segwit if it's selected but network doesn't support it if (segwitSelected() && !networkHasSegwit()) { + showSegwitUnavailable(); return; } + showSegwitAvailable(); // Get the derivation path var derivationPath = getDerivationPath(); var errorText = findDerivationPathErrors(derivationPath); @@ -1393,7 +1389,20 @@ } function networkHasSegwit() { - return networks[DOM.network.val()].segwitAvailable; + var n = network; + if ("baseNetwork" in network) { + n = bitcoinjs.bitcoin.networks[network.baseNetwork]; + } + // check if only p2wpkh params are required + if (p2wpkhSelected()) { + return "p2wpkh" in n; + } + // check if only p2wpkh-in-p2sh params are required + else if (p2wpkhInP2shSelected()) { + return "p2wpkhInP2sh" in n; + } + // require both if it's unclear which params are required + return "p2wpkh" in n && "p2wpkhInP2sh" in n; } function bip49TabSelected() { @@ -1542,7 +1551,6 @@ var networks = [ { name: "AC - Asiacoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.asiacoin; setHdCoin(51); @@ -1550,7 +1558,6 @@ }, { name: "ACC - Adcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.adcoin; setHdCoin(161); @@ -1558,7 +1565,6 @@ }, { name: "AUR - Auroracoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.auroracoin; setHdCoin(85); @@ -1566,7 +1572,6 @@ }, { name: "AXE - Axe", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.axe; setHdCoin(4242); @@ -1574,7 +1579,6 @@ }, { name: "BCA - Bitcoin Atom", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.atom; setHdCoin(185); @@ -1582,7 +1586,6 @@ }, { name: "BCH - Bitcoin Cash", - segwitAvailable: false, onSelect: function() { DOM.bitcoinCashAddressTypeContainer.removeClass("hidden"); setHdCoin(145); @@ -1590,7 +1593,6 @@ }, { name: "BEET - Beetlecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.beetlecoin; setHdCoin(800); @@ -1598,7 +1600,6 @@ }, { name: "BELA - Belacoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.belacoin; setHdCoin(73); @@ -1606,7 +1607,6 @@ }, { name: "BLK - BlackCoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.blackcoin; setHdCoin(10); @@ -1614,7 +1614,6 @@ }, { name: "BRIT - Britcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.britcoin; setHdCoin(70); @@ -1622,7 +1621,6 @@ }, { name: "BSD - Bitsend", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitsend; setHdCoin(91); @@ -1630,7 +1628,6 @@ }, { name: "BTA - Bata", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.bata; setHdCoin(89); @@ -1638,7 +1635,6 @@ }, { name: "BTC - Bitcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoin; setHdCoin(0); @@ -1646,7 +1642,6 @@ }, { name: "BTC - Bitcoin Testnet", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.testnet; setHdCoin(1); @@ -1654,7 +1649,6 @@ }, { name: "BTCP - Bitcoin Private", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoinprivate; setHdCoin(183); @@ -1662,7 +1656,6 @@ }, { name: "BTCZ - Bitcoinz", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoinz; setHdCoin(177); @@ -1670,7 +1663,6 @@ }, { name: "BTG - Bitcoin Gold", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.bgold; setHdCoin(156); @@ -1678,7 +1670,6 @@ }, { name: "BTX - Bitcore", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcore; setHdCoin(160); @@ -1686,7 +1677,6 @@ }, { name: "CCN - Cannacoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.cannacoin; setHdCoin(19); @@ -1694,7 +1684,6 @@ }, { name: "CDN - Canadaecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.canadaecoin; setHdCoin(34); @@ -1702,7 +1691,6 @@ }, { name: "CLAM - Clams", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.clam; setHdCoin(23); @@ -1710,7 +1698,6 @@ }, { name: "CLUB - Clubcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.clubcoin; setHdCoin(79); @@ -1718,7 +1705,6 @@ }, { name: "CMP - Compcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.compcoin; setHdCoin(71); @@ -1726,7 +1712,6 @@ }, { name: "CRAVE - Crave", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.crave; setHdCoin(186); @@ -1734,7 +1719,6 @@ }, { name: "CRW - Crown", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.crown; setHdCoin(72); @@ -1742,7 +1726,6 @@ }, { name: "DASH - Dash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.dash; setHdCoin(5); @@ -1750,7 +1733,6 @@ }, { name: "DASH - Dash Testnet", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.dashtn; setHdCoin(1); @@ -1758,7 +1740,6 @@ }, { name: "DFC - Defcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.defcoin; setHdCoin(1337); @@ -1766,7 +1747,6 @@ }, { name: "DGB - Digibyte", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.digibyte; setHdCoin(20); @@ -1774,7 +1754,6 @@ }, { name: "DGC - Digitalcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.digitalcoin; setHdCoin(18); @@ -1782,7 +1761,6 @@ }, { name: "DMD - Diamond", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.diamond; setHdCoin(152); @@ -1790,7 +1768,6 @@ }, { name: "DNR - Denarius", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.denarius; setHdCoin(116); @@ -1798,7 +1775,6 @@ }, { name: "DOGE - Dogecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.dogecoin; setHdCoin(3); @@ -1806,7 +1782,6 @@ }, { name: "ECN - Ecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.ecoin; setHdCoin(115); @@ -1814,7 +1789,6 @@ }, { name: "EDRC - Edrcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.edrcoin; setHdCoin(56); @@ -1822,7 +1796,6 @@ }, { name: "EFL - Egulden", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.egulden; setHdCoin(78); @@ -1830,7 +1803,6 @@ }, { name: "EMC2 - Einsteinium", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.einsteinium; setHdCoin(41); @@ -1838,7 +1810,6 @@ }, { name: "ERC - Europecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.europecoin; setHdCoin(151); @@ -1846,7 +1817,6 @@ }, { name: "ETH - Ethereum", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoin; setHdCoin(60); @@ -1854,7 +1824,6 @@ }, { name: "EXCL - Exclusivecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.exclusivecoin; setHdCoin(190); @@ -1862,7 +1831,6 @@ }, { name: "FJC - Fujicoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.fujicoin; setHdCoin(75); @@ -1870,7 +1838,6 @@ }, { name: "FLASH - Flashcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.flashcoin; setHdCoin(120); @@ -1878,7 +1845,6 @@ }, { name: "FRST - Firstcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.firstcoin; setHdCoin(167); @@ -1886,7 +1852,6 @@ }, { name: "FTC - Feathercoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.feathercoin; setHdCoin(8); @@ -1894,7 +1859,6 @@ }, { name: "GAME - GameCredits", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.game; setHdCoin(101); @@ -1902,7 +1866,6 @@ }, { name: "GBX - Gobyte", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.gobyte; setHdCoin(176); @@ -1910,7 +1873,6 @@ }, { name: "GCR - GCRCoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.gcr; setHdCoin(79); @@ -1918,7 +1880,6 @@ }, { name: "GRC - Gridcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.gridcoin; setHdCoin(84); @@ -1926,7 +1887,6 @@ }, { name: "HNC - Helleniccoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.helleniccoin; setHdCoin(168); @@ -1934,7 +1894,6 @@ }, { name: "INSN - Insane", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.insane; setHdCoin(68); @@ -1942,7 +1901,6 @@ }, { name: "IOP - Iop", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.iop; setHdCoin(66); @@ -1950,7 +1908,6 @@ }, { name: "IXC - Ixcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.ixcoin; setHdCoin(86); @@ -1958,7 +1915,6 @@ }, { name: "JBS - Jumbucks", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.jumbucks; setHdCoin(26); @@ -1982,7 +1938,6 @@ }, { name: "LBC - Library Credits", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.lbry; setHdCoin(140); @@ -1990,7 +1945,6 @@ }, { name: "LCC - Litecoincash", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.litecoincash; setHdCoin(192); @@ -1998,7 +1952,6 @@ }, { name: "LDCN - Landcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.landcoin; setHdCoin(63); @@ -2006,7 +1959,6 @@ }, { name: "LINX - Linx", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.linx; setHdCoin(114); @@ -2014,7 +1966,6 @@ }, { name: "LTC - Litecoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.litecoin; setHdCoin(2); @@ -2023,7 +1974,6 @@ }, { name: "LYNX - Lynx", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.lynx; setHdCoin(191); @@ -2031,7 +1981,6 @@ }, { name: "MAZA - Maza", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.maza; setHdCoin(13); @@ -2039,7 +1988,6 @@ }, { name: "MNX - Minexcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.minexcoin; setHdCoin(182); @@ -2047,7 +1995,6 @@ }, { name: "MONA - Monacoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.monacoin, setHdCoin(22); @@ -2055,7 +2002,6 @@ }, { name: "NAV - Navcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.navcoin; setHdCoin(130); @@ -2063,7 +2009,6 @@ }, { name: "NEBL - Neblio", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.neblio; setHdCoin(146); @@ -2071,7 +2016,6 @@ }, { name: "NEOS - Neoscoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.neoscoin; setHdCoin(25); @@ -2079,7 +2023,6 @@ }, { name: "NLG - Gulden", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.gulden; setHdCoin(87); @@ -2087,7 +2030,6 @@ }, { name: "NMC - Namecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.namecoin; setHdCoin(7); @@ -2095,7 +2037,6 @@ }, { name: "NRG - Energi", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.energi; setHdCoin(204); @@ -2103,7 +2044,6 @@ }, { name: "NRO - Neurocoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.neurocoin; setHdCoin(110); @@ -2111,7 +2051,6 @@ }, { name: "NSR - Nushares", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.nushares; setHdCoin(11); @@ -2119,7 +2058,6 @@ }, { name: "NYC - Newyorkc", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.newyorkc; setHdCoin(179); @@ -2127,7 +2065,6 @@ }, { name: "NVC - Novacoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.novacoin; setHdCoin(50); @@ -2135,7 +2072,6 @@ }, { name: "OK - Okcash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.okcash; setHdCoin(69); @@ -2143,7 +2079,6 @@ }, { name: "OMNI - Omnicore", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.omnicore; setHdCoin(200); @@ -2151,7 +2086,6 @@ }, { name: "ONX - Onixcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.onixcoin; setHdCoin(174); @@ -2159,7 +2093,6 @@ }, { name: "PINK - Pinkcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.pinkcoin; setHdCoin(117); @@ -2167,7 +2100,6 @@ }, { name: "PIVX - PIVX", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.pivx; setHdCoin(119); @@ -2175,7 +2107,6 @@ }, { name: "PIVX - PIVX Testnet", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.pivxtestnet; setHdCoin(1); @@ -2183,7 +2114,6 @@ }, { name: "POSW - POSWcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.poswcoin; setHdCoin(47); @@ -2191,7 +2121,6 @@ }, { name: "POT - Potcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.potcoin; setHdCoin(81); @@ -2199,7 +2128,6 @@ }, { name: "PPC - Peercoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.peercoin; setHdCoin(6); @@ -2207,7 +2135,6 @@ }, { name: "PSB - Pesobit", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.pesobit; setHdCoin(62); @@ -2215,7 +2142,6 @@ }, { name: "PUT - Putincoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.putincoin; setHdCoin(122); @@ -2223,7 +2149,6 @@ }, { name: "RBY - Rubycoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.rubycoin; setHdCoin(16); @@ -2231,7 +2156,6 @@ }, { name: "RDD - Reddcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.reddoin; setHdCoin(4); @@ -2239,7 +2163,6 @@ }, { name: "RVR - RevolutionVR", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.revolutionvr; setHdCoin(129); @@ -2247,7 +2170,6 @@ }, { name: "SDC - ShadowCash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.shadow; setHdCoin(35); @@ -2255,7 +2177,6 @@ }, { name: "SDC - ShadowCash Testnet", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.shadowtn; setHdCoin(1); @@ -2263,7 +2184,6 @@ }, { name: "SLM - Slimcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.slimcoin; setHdCoin(63); @@ -2271,7 +2191,6 @@ }, { name: "SLM - Slimcoin Testnet", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.slimcointn; setHdCoin(111); @@ -2279,7 +2198,6 @@ }, { name: "SLR - Solarcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.solarcoin; setHdCoin(58); @@ -2287,7 +2205,6 @@ }, { name: "SMLY - Smileycoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.smileycoin; setHdCoin(59); @@ -2295,7 +2212,6 @@ }, { name: "STRAT - Stratis", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.stratis; setHdCoin(105); @@ -2303,7 +2219,6 @@ }, { name: "SYS - Syscoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.syscoin; setHdCoin(57); @@ -2311,7 +2226,6 @@ }, { name: "THC - Hempcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.hempcoin; setHdCoin(113); @@ -2319,7 +2233,6 @@ }, { name: "TOA - Toa", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.toa; setHdCoin(159); @@ -2327,7 +2240,6 @@ }, { name: "USC - Ultimatesecurecash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.ultimatesecurecash; setHdCoin(112); @@ -2335,7 +2247,6 @@ }, { name: "USNBT - NuBits", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.nubits; setHdCoin(12); @@ -2343,7 +2254,6 @@ }, { name: "UNO - Unobtanium", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.unobtanium; setHdCoin(92); @@ -2351,7 +2261,6 @@ }, { name: "VASH - Vpncoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.vpncoin; setHdCoin(33); @@ -2359,7 +2268,6 @@ }, { name: "VIA - Viacoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.viacoin; setHdCoin(14); @@ -2367,7 +2275,6 @@ }, { name: "VIA - Viacoin Testnet", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.viacointestnet; setHdCoin(1); @@ -2375,7 +2282,6 @@ }, { name: "VIVO - Vivo", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.vivo; setHdCoin(166); @@ -2383,7 +2289,6 @@ }, { name: "VTC - Vertcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.vertcoin; setHdCoin(28); @@ -2391,7 +2296,6 @@ }, { name: "WC - Wincoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.wincoin; setHdCoin(181); @@ -2399,7 +2303,6 @@ }, { name: "XBC - Bitcoinplus", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoinplus; setHdCoin(65); @@ -2407,7 +2310,6 @@ }, { name: "XMY - Myriadcoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.myriadcoin; setHdCoin(90); @@ -2415,7 +2317,6 @@ }, { name: "XRP - Ripple", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.bitcoin; setHdCoin(144); @@ -2423,7 +2324,6 @@ }, { name: "XVC - Vcash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.vcash; setHdCoin(127); @@ -2431,7 +2331,6 @@ }, { name: "XVG - Verge", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.verge; setHdCoin(77); @@ -2439,7 +2338,6 @@ }, { name: "XWC - Whitecoin", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.whitecoin; setHdCoin(155); @@ -2447,7 +2345,6 @@ }, { name: "XZC - Zcoin", - segwitAvailable: true, onSelect: function() { network = bitcoinjs.bitcoin.networks.zcoin; setHdCoin(136); @@ -2455,7 +2352,6 @@ }, { name: "ZCL - Zclassic", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.zclassic; setHdCoin(147); @@ -2463,7 +2359,6 @@ }, { name: "ZEC - Zcash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.zcash; setHdCoin(133); @@ -2471,7 +2366,6 @@ }, { name: "XUEZ - Xuez", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.xuez; setHdCoin(225); @@ -2479,7 +2373,6 @@ }, { name: "ZEN - Zencash", - segwitAvailable: false, onSelect: function() { network = bitcoinjs.bitcoin.networks.zencash; setHdCoin(121); From 530648c174dc295b47c22db7df4ea6753273efa6 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 09:22:14 +1000 Subject: [PATCH 08/15] Add litecoin segwit tests --- tests/spec/tests.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 94fc672..5ddd686 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -3643,4 +3643,42 @@ it('Does not show a warning if entropy is stronger than mnemonic length', functi }); }); +it('Shows a warning for litecoin BIP84 (which does not have p2wpkh params)', function(done) { + driver.findElement(By.css('.phrase')) + .sendKeys('abandon abandon ability'); + selectNetwork("LTC - Litecoin"); + driver.findElement(By.css('#bip84-tab a')) + .click() + // bip84 unavailable is shown + driver.sleep(feedbackDelay).then(function() { + driver.findElement(By.css('#bip84 .unavailable')) + .getAttribute("class") + .then(function(classes) { + expect(classes).not.toContain("hidden"); + done(); + }); + }); +}); + +it('Shows litecoin BIP49 addresses', function(done) { + driver.findElement(By.css('.phrase')) + .sendKeys('abandon abandon ability'); + selectNetwork("LTC - Litecoin"); + driver.findElement(By.css('#bip49-tab a')) + .click() + // bip49 addresses are shown + driver.sleep(generateDelay).then(function() { + driver.findElement(By.css('#bip49 .available')) + .getAttribute("class") + .then(function(classes) { + expect(classes).not.toContain("hidden"); + // check first address + getFirstAddress(function(address) { + expect(address).toBe("MFwLPhsXoBuSLL8cLmW9uK6tChkzduV8qN"); + done(); + }); + }); + }); +}); + }); From 7733ac322b60127fa8d845f90e7605625996c9d1 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 09:42:03 +1000 Subject: [PATCH 09/15] Hide 'calculating' feedback if segwit unavailable --- src/js/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/index.js b/src/js/index.js index c9bbdc6..ff35755 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -369,6 +369,7 @@ // Don't show segwit if it's selected but network doesn't support it if (segwitSelected() && !networkHasSegwit()) { showSegwitUnavailable(); + hidePending(); return; } showSegwitAvailable(); From 6f7fa3539e4f2cf3be19ebfbd4a914bf0992ca88 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 10:21:21 +1000 Subject: [PATCH 10/15] Parse extended root key regardless of prefix --- src/js/index.js | 62 +++++++++++++++++++++++++++++++++++++++++++++ tests/spec/tests.js | 19 ++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/src/js/index.js b/src/js/index.js index ff35755..bfaf879 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -478,6 +478,37 @@ } function calcBip32RootKeyFromBase58(rootKeyBase58) { + // try parsing with various segwit network params since this extended + // key may be from any one of them. + if (networkHasSegwit()) { + var n = network; + if ("baseNetwork" in n) { + n = bitcoinjs.bitcoin.networks[n.baseNetwork]; + } + // try parsing using base network params + try { + bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n); + return; + } + catch (e) {} + // try parsing using p2wpkh params + if ("p2wpkh" in n) { + try { + bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh); + return; + } + catch (e) {} + } + // try parsing using p2wpkh-in-p2sh network params + if ("p2wpkhInP2sh" in n) { + try { + bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh); + return; + } + catch (e) {} + } + } + // try the network params as currently specified bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network); } @@ -551,6 +582,37 @@ } function validateRootKey(rootKeyBase58) { + // try various segwit network params since this extended key may be from + // any one of them. + if (networkHasSegwit()) { + var n = network; + if ("baseNetwork" in n) { + n = bitcoinjs.bitcoin.networks[n.baseNetwork]; + } + // try parsing using base network params + try { + bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n); + return ""; + } + catch (e) {} + // try parsing using p2wpkh params + if ("p2wpkh" in n) { + try { + bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkh); + return ""; + } + catch (e) {} + } + // try parsing using p2wpkh-in-p2sh network params + if ("p2wpkhInP2sh" in n) { + try { + bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh); + return ""; + } + catch (e) {} + } + } + // try the network params as currently specified try { bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network); } diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 5ddd686..b90906b 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -3681,4 +3681,23 @@ it('Shows litecoin BIP49 addresses', function(done) { }); }); +it('Can use root keys to generate segwit table rows', function(done) { + // segwit uses ypub / zpub instead of xpub but the root key should still + // be valid regardless of the encoding used to import that key. + // Maybe this breaks the reason for the different extended key prefixes, but + // since the parsed root key is used behind the scenes anyhow this should be + // allowed. + driver.findElement(By.css('#root-key')) + .sendKeys('xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi'); + driver.findElement(By.css('#bip49-tab a')) + .click() + // bip49 addresses are shown + driver.sleep(generateDelay).then(function() { + getFirstAddress(function(address) { + expect(address).toBe("3QG2Y9AA4xZ846gKHZqNf7mvVKbLqMKxr2"); + done(); + }); + }); +}); + }); From 0b6e351dce55d6f139facf59aca50b9fca62c289 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 10:56:47 +1000 Subject: [PATCH 11/15] Add visual privacy safeguard for private data --- src/css/app.css | 3 +++ src/index.html | 39 ++++++++++++++++++++++++--------------- src/js/index.js | 13 +++++++++++++ 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/css/app.css b/src/css/app.css index 71109ef..576b7d7 100644 --- a/src/css/app.css +++ b/src/css/app.css @@ -103,3 +103,6 @@ body { overflow-x: scroll; font-family: monospace; } +.visual-privacy .private-data { + display: none; +} diff --git a/src/index.html b/src/index.html index ea667ee..419ada0 100644 --- a/src/index.html +++ b/src/index.html @@ -69,7 +69,7 @@
- + -
+
-
+
-
 
+
 
-
 
+
 
+ Hide all private info + +
+
@@ -160,19 +169,19 @@
- +
- +
- +
@@ -186,7 +195,7 @@
- +
@@ -439,7 +448,7 @@ Account Extended Private Key
- +
@@ -566,7 +575,7 @@ Account Extended Private Key
- +
@@ -598,7 +607,7 @@
- +
@@ -644,7 +653,7 @@ Encrypt private keys using BIP38 and this password: - + Enabling BIP38 means each key will take several minutes to generate.
@@ -909,7 +918,7 @@ - + diff --git a/src/js/index.js b/src/js/index.js index bfaf879..40d15f4 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -23,6 +23,7 @@ var generationProcesses = []; var DOM = {}; + DOM.privacyScreenToggle = $(".privacy-screen-toggle"); DOM.network = $(".network"); DOM.bip32Client = $("#bip32-client"); DOM.phraseNetwork = $("#network-phrase"); @@ -118,6 +119,7 @@ function init() { // Events + DOM.privacyScreenToggle.on("change", privacyScreenToggled); DOM.generatedStrength.on("change", generatedStrengthChanged); DOM.network.on("change", networkChanged); DOM.bip32Client.on("change", bip32ClientChanged); @@ -447,6 +449,17 @@ $("td.privkey span").toggleClass("invisible"); } + function privacyScreenToggled() { + // private-data contains elements added to DOM at runtime + // so catch all by adding visual privacy class to the root of the DOM + if (DOM.privacyScreenToggle.prop("checked")) { + $("body").addClass("visual-privacy"); + } + else { + $("body").removeClass("visual-privacy"); + } + } + // Private methods function generateRandomPhrase() { From 6db7516d4ad83794c9c89634597fc7503fa7de81 Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 11:20:04 +1000 Subject: [PATCH 12/15] Fix typo - reddoin/reddcoin --- src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/index.js b/src/js/index.js index 40d15f4..1b56d6c 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -2233,7 +2233,7 @@ { name: "RDD - Reddcoin", onSelect: function() { - network = bitcoinjs.bitcoin.networks.reddoin; + network = bitcoinjs.bitcoin.networks.reddcoin; setHdCoin(4); }, }, From 2ab3faf414af6f37918d207f13da4183a548869a Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 11:20:32 +1000 Subject: [PATCH 13/15] Fix tests for altcoins Checked reddcoin address in block explorer https://live.reddcoin.com AXE params were updated in https://github.com/iancoleman/bip39/pull/213 but not the test. --- tests/spec/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/spec/tests.js b/tests/spec/tests.js index b90906b..b81294b 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js @@ -616,7 +616,7 @@ it('Allows selection of monacoin', function(done) { it('Allows selection of AXE', function(done) { var params = { selectText: "AXE - Axe", - firstAddress: "XQ4HLxUVS3egk5ff1o9e2vJFJKSSsUH3B7", + firstAddress: "PScwtLUyPiGrqtKXrHF37DGETLXLZdw4up", }; testNetwork(done, params); }); @@ -1057,7 +1057,7 @@ it('Allows selection of Putincoin', function(done) { it('Allows selection of Reddcoin', function(done) { var params = { selectText: "RDD - Reddcoin", - firstAddress: "1M4druAcUfkXBaAcQ4cCgCLPHChiaib6kL", + firstAddress: "RtgRvXMBng1y51ftteveFqwNfyRG18HpxQ", }; testNetwork(done, params); }); From 4218c87458e07a2af23535103b7900159b83846e Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Tue, 29 May 2018 11:46:48 +1000 Subject: [PATCH 14/15] Release v0.3.7 --- bip39-standalone.html | 521 +++++++++++++++++++++++++----------------- changelog.md | 12 + src/index.html | 2 +- 3 files changed, 329 insertions(+), 206 deletions(-) diff --git a/bip39-standalone.html b/bip39-standalone.html index 35a88d7..a559e9d 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html @@ -6866,6 +6866,9 @@ button.close { overflow-x: scroll; font-family: monospace; } +.visual-privacy .private-data { + display: none; +} @@ -6877,7 +6880,7 @@ button.close {

Mnemonic Code Converter

-

v0.3.6

+

v0.3.7


@@ -6931,7 +6934,7 @@ button.close {
- + -
+
-
+
-
 
+
 
-
 
+
 
+ Hide all private info + +
+
@@ -7022,19 +7034,19 @@ button.close {
- +
- +
- +
@@ -7048,7 +7060,7 @@ button.close {
- +
@@ -7301,7 +7313,7 @@ button.close { Account Extended Private Key
- +
@@ -7368,79 +7380,89 @@ button.close {

-
-
-

- For more info see the - BIP84 spec. -

-
-
- -
- + -
- +
+
- +

+ For more info see the + BIP84 spec. +

-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
-

The account extended keys can be used for importing to most BIP84 compatible wallets.

+
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+

The account extended keys can be used for importing to most BIP84 compatible wallets.

+
-
-
- -
-

The BIP32 derivation path and extended keys are the basis for the derived addresses.

+
+ +
+ +
-
-
- -
- +
+ +
+ +
+
+
+ +
+

The BIP32 derivation path and extended keys are the basis for the derived addresses.

+
+
+
+ +
+ +
@@ -7450,7 +7472,7 @@ button.close {
- +
@@ -7496,7 +7518,7 @@ button.close { Encrypt private keys using BIP38 and this password: - + Enabling BIP38 means each key will take several minutes to generate.
@@ -7761,7 +7783,7 @@ button.close { - + + +bitcoinjs.bitcoin.networks.xuez = { + messagePrefix: 'unused', + bip32: { + public: 0x022d2533, + private: 0x0221312b + }, + pubKeyHash: 0x4b, + scriptHash: 0x12, + wif: 0xd4 +}; + +bitcoinjs.bitcoin.networks.bitcoinprivate = { + messagePrefix: '\x18BitcoinPrivate Signed Message:\n', + bip32: { + public: 0x0488B21E, + private: 0x0488ADE4, + }, + pubKeyHash: 0x1325, + scriptHash: 0x13AF, + wif: 0x80, +}; + +bitcoinjs.bitcoin.networks.bitcoinz = { + messagePrefix: '\x18BitcoinZ Signed Message:\n', + bip32: { + public: 0x0488B21E, + private: 0x0488ADE4, + }, + pubKeyHash: 0x1CB8, + scriptHash: 0x1CBD, + wif: 0x80, +}; + +bitcoinjs.bitcoin.networks.zclassic = { + messagePrefix: '\x18Zcash Signed Message:\n', + bip32: { + public: 0x0488B21E, + private: 0x0488ADE4, + }, + pubKeyHash: 0x1CB8, + scriptHash: 0x1CBD, + wif: 0x80, +}; + +bitcoinjs.bitcoin.networks.zencash = { + messagePrefix: '\x18Zcash Signed Message:\n', + bip32: { + public: 0x0488B21E, + private: 0x0488ADE4, + }, + pubKeyHash: 0x2089, + scriptHash: 0x2096, + wif: 0x80, +}; + +bitcoinjs.bitcoin.networks.energi = { + messagePrefix: 'DarkCoin Signed Message:\n', + bip32: { + public: 0x03B8C856, + private: 0xD7DC6E9F, + }, + pubKeyHash: 0x21, + scriptHash: 0x35, + wif: 0x6a, +};