Compare commits

...

33 Commits
0.2.1 ... 0.2.6

Author SHA1 Message Date
Ian Coleman
9ff30babbc Release v0.2.6 2017-09-20 11:39:06 +10:00
Ian Coleman
ee0981f1ec Detect and warn of filtered entropy 2017-09-20 11:25:21 +10:00
Ian Coleman
6024e655a8 Update process for committing changes
Do not include changes in bip39-standalone.html
2017-09-19 11:15:25 +10:00
Ian Coleman
7e6bdc498e Reword entropy text to say one type, not multiple 2017-09-19 11:13:03 +10:00
iancoleman
16b4c2788a Merge pull request #117 from jonathancross/iancoleman-bip39-bip49
Adding BIP 49 to "More info" section.
2017-09-19 10:32:20 +10:00
iancoleman
0197de2795 Merge pull request #116 from jonathancross/iancoleman-bip39-compile
Allowing compilation with Python 2.x
2017-09-19 10:26:32 +10:00
Jonathan Cross
861750ae51 Adding BIP 49 to "More info" section. 2017-09-18 02:18:51 +02:00
Jonathan Cross
a40d59d904 Allowing compilation with Python 2.x and 3. 2017-09-18 01:57:05 +02:00
iancoleman
d933c3f731 Merge pull request #103 from Zwilla/patch-3
correctLevel from 2 to 3
2017-09-08 08:12:34 +10:00
iancoleman
408ecc184a Merge pull request #102 from Zwilla/patch-2
remove sourceMappingURL=zxcvbn.js.map
2017-09-08 08:07:51 +10:00
Zwilla
00114002fe correctLevel from 2 to 3
correctLevel 3 is generally recommended for industrial environments.

See also: https://github.com/iancoleman/bip39/issues/101
2017-09-07 14:32:42 +02:00
Zwilla
e80955983d remove sourceMappingURL=zxcvbn.js.map
just remove this line, if not every time we run the converter it searches for the map file. It is not enough to uncomment this line.
thx
2017-09-07 09:42:54 +02:00
iancoleman
f20b7e7128 Merge pull request #98 from Zwilla/patch-1
changed some wrong comma and ;
2017-09-04 10:03:05 +10:00
Zwilla
908dc06fe8 changed some wrong comma and ;
nothing else
2017-09-04 01:55:55 +02:00
Ian Coleman
3d548c6f9b Improve release process order and add details 2017-09-01 13:20:29 +10:00
Ian Coleman
0a8d06d03e Release v0.2.5 2017-09-01 12:35:42 +10:00
Ian Coleman
88311463c7 Allow P2WPKH nested in P2SH addresses on BIP32 tab 2017-09-01 12:28:27 +10:00
Ian Coleman
cd7c8327b1 Validate root key correctly for alternate networks 2017-09-01 12:27:03 +10:00
Ian Coleman
0cda44d5f6 Rename bip49 to p2wpkhNestedInP2sh where suitable 2017-09-01 12:25:45 +10:00
Ian Coleman
7258b102c1 Add confirmation steps to the release process 2017-08-28 10:03:21 +10:00
Ian Coleman
8d18f379fd Release v0.2.4 2017-08-28 09:48:48 +10:00
Ian Coleman
3abab9b087 Add a checkbox to switch litecoin key prefixes 2017-08-28 09:45:38 +10:00
Ian Coleman
b18eb97ae3 Show error when using xpub with hardened addresses 2017-08-24 09:37:21 +10:00
Ian Coleman
88ea3e40ee Release v0.2.3 2017-08-23 09:45:09 +10:00
Ian Coleman
8a9f391376 Test for Maza network 2017-08-23 09:41:53 +10:00
iancoleman
e40acc3ab0 Merge pull request #92 from jonspock/master
Add maza coin, update PIVX in bip39-standalone.html
2017-08-23 09:30:43 +10:00
Jon Spock
56ad960105 Add maza coin 2017-08-21 17:13:44 -07:00
Ian Coleman
f128bd58c4 Release v0.2.2 2017-08-16 11:26:10 +10:00
Ian Coleman
0eda54f5a7 Improve showing feedback for pending calculations 2017-08-16 11:04:13 +10:00
Ian Coleman
ed6d9d3905 Clear old seed when mnemonic is changed 2017-08-16 10:43:09 +10:00
Ian Coleman
47b64d3ee1 Add PIVX network tests 2017-08-14 15:27:24 +10:00
iancoleman
bc33f5ee53 Merge pull request #89 from alkley/master
Add PIVX
2017-08-14 14:43:04 +10:00
alkley
c0df01895d Added PIVX 2017-08-11 15:08:53 +02:00
12 changed files with 772 additions and 170 deletions

View File

@@ -118,7 +118,7 @@
<div class="container">
<h1 class="text-center">Mnemonic Code Converter</h1>
<p class="version">v0.2.1</p>
<p class="version">v0.2.6</p>
<hr>
<div class="row">
<div class="col-md-12">
@@ -167,7 +167,14 @@
<div class="form-group">
<label for="entropy" class="col-sm-2 control-label" data-translate>Entropy</label>
<div class="col-sm-7">
<textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea>
<textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" data-translate-placeholder></textarea>
<div class="row filter-warning text-danger hidden">
<p class="col-sm-12">
<strong>
Some characters have been discarded
</strong>
</p>
</div>
<div class="row">
<label class="col-sm-3 control-label" data-translate><span class="more-info" data-translate-title title="Based on estimates from zxcvbn using Filtered Entropy">Time To Crack</span></label>
<div class="crack-time col-sm-3 form-control-static"></div>
@@ -270,6 +277,15 @@
<textarea id="root-key" class="root-key form-control" data-show-qr></textarea>
</div>
</div>
<div class="form-group litecoin-ltub-container hidden">
<label for="litecoin-use-ltub" class="col-sm-2 control-label" data-translate>Prefixes</label>
<div class="col-sm-10 checkbox">
<label>
<input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub">
Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code>
</label>
</div>
</div>
</form>
</div>
</div>
@@ -403,6 +419,13 @@
<span data-translate>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 data-translate>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" data-translate>Bitcoin Core</label>
<div class="col-sm-10">
@@ -621,6 +644,11 @@
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
</p>
<h3>BIP49 <span class="small" data-translate>Derivation scheme for P2WPKH-nested-in-P2SH based accounts</span></h3>
<p data-translate-html>
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki" target="_blank">official BIP49 spec</a>
</p>
<h3 data-translate>Private Keys</h3>
<p>
<span data-translate-html>
@@ -7271,7 +7299,7 @@ this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(
55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,
45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];p.getRSBlocks=function(a,c){var d=p.getRsBlockTable(a,c);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+c);for(var b=d.length/3,e=[],f=0;f<b;f++)for(var h=d[3*f+0],g=d[3*f+1],j=d[3*f+2],l=0;l<h;l++)e.push(new p(g,j));return e};p.getRsBlockTable=function(a,c){switch(c){case 1:return p.RS_BLOCK_TABLE[4*(a-1)+0];case 0:return p.RS_BLOCK_TABLE[4*(a-1)+1];case 3:return p.RS_BLOCK_TABLE[4*
(a-1)+2];case 2:return p.RS_BLOCK_TABLE[4*(a-1)+3]}};t.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,c){for(var d=0;d<c;d++)this.putBit(1==(a>>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,
correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
correctLevel:3,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
j=Math.ceil((f+1)*b)-Math.floor(f*b);d.fillRect(Math.round(i*b),Math.round(f*e),g,j)}}else{a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();c=r("<table></table>").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e<a.getModuleCount();e++){f=r("<tr></tr>").css("height",b+"px").appendTo(c);for(i=0;i<a.getModuleCount();i++)r("<td></td>").css("width",
d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;$(a).appendTo(this)})}})($);
</script>
@@ -16926,6 +16954,16 @@ module.exports = {
wif: 0xef
},
litecoin: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4,
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
},
litecoinLtub: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
@@ -22104,126 +22142,138 @@ module.exports = {
}).call(this,require("buffer").Buffer)
},{"bs58check":80,"buffer":4}]},{},[33])(33)
});</script>
});
</script>
<script>bitcoinjs.bitcoin.networks.shadow = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xEE80286A,
private: 0xEE8031E8
},
pubKeyHash: 0x3f,
scriptHash: 0x7d,
wif: 0xbf,
wif: 0xbf
};
bitcoinjs.bitcoin.networks.shadowtn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x76C0FDFB,
private: 0x76C1077A
},
pubKeyHash: 0x7f,
scriptHash: 0xc4,
wif: 0xff,
wif: 0xff
};
bitcoinjs.bitcoin.networks.clam = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xa8c26d64,
private: 0xa8c17826
},
pubKeyHash: 0x89,
scriptHash: 0x00, // TODO set this correctly
wif: 0x85,
wif: 0x85
};
bitcoinjs.bitcoin.networks.crown = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
wif: 0x80
};
bitcoinjs.bitcoin.networks.dash = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x4c,
scriptHash: 0x10,
wif: 0xcc,
wif: 0xcc
};
bitcoinjs.bitcoin.networks.maza = {
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x09,
wif: 0xe0
};
bitcoinjs.bitcoin.networks.dashtn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x8c,
scriptHash: 0x13,
wif: 0xef,
wif: 0xef
};
bitcoinjs.bitcoin.networks.game = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x26,
scriptHash: 0x05,
wif: 0xa6,
wif: 0xa6
};
bitcoinjs.bitcoin.networks.namecoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x34,
scriptHash: 0x00, // TODO set this correctly
wif: 0x80,
wif: 0x80
};
bitcoinjs.bitcoin.networks.peercoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x37,
scriptHash: 0x00, // TODO set this correctly
wif: 0xb7,
wif: 0xb7
};
bitcoinjs.bitcoin.networks.slimcoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xef6adf10,
private: 0xef69ea80
},
pubKeyHash: 0x3f,
scriptHash: 0x7d,
wif: 0x46,
wif: 0x46
};
bitcoinjs.bitcoin.networks.slimcointn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x043587CF,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0x57,
wif: 0x57
};
bitcoinjs.bitcoin.networks.dogecoin = {
@@ -22234,8 +22284,8 @@ bitcoinjs.bitcoin.networks.dogecoin = {
},
pubKeyHash: 0x1e,
scriptHash: 0x16,
wif: 0x9e,
},
wif: 0x9e
};
bitcoinjs.bitcoin.networks.viacoin = {
messagePrefix: '\x18Viacoin Signed Message:\n',
@@ -22245,8 +22295,8 @@ bitcoinjs.bitcoin.networks.viacoin = {
},
pubKeyHash: 0x47,
scriptHash: 0x21,
wif: 0xc7,
},
wif: 0xc7
};
bitcoinjs.bitcoin.networks.viacointestnet = {
messagePrefix: '\x18Viacoin Signed Message:\n',
@@ -22256,8 +22306,8 @@ bitcoinjs.bitcoin.networks.viacointestnet = {
},
pubKeyHash: 0x7f,
scriptHash: 0xc4,
wif: 0xff,
},
wif: 0xff
};
bitcoinjs.bitcoin.networks.gamerscoin = {
messagePrefix: '\x19Gamerscoin Signed Message:\n',
@@ -22267,8 +22317,8 @@ bitcoinjs.bitcoin.networks.gamerscoin = {
},
pubKeyHash: 0x26,
scriptHash: 0x05,
wif: 0xA6,
},
wif: 0xA6
};
bitcoinjs.bitcoin.networks.jumbucks = {
messagePrefix: '\x19Jumbucks Signed Message:\n',
@@ -22278,8 +22328,8 @@ bitcoinjs.bitcoin.networks.jumbucks = {
},
pubKeyHash: 0x2b,
scriptHash: 0x05,
wif: 0xab,
},
wif: 0xab
};
bitcoinjs.bitcoin.networks.zetacoin = {
messagePrefix: '\x18Zetacoin Signed Message:\n',
@@ -22289,18 +22339,40 @@ bitcoinjs.bitcoin.networks.zetacoin = {
},
pubKeyHash: 0x50,
scriptHash: 0x09,
wif: 0xe0,
}
wif: 0xe0
};
bitcoinjs.bitcoin.networks.myriadcoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x00, // TODO set this correctly
wif: 0xb2,
wif: 0xb2
};
bitcoinjs.bitcoin.networks.pivx = {
messagePrefix: 'unused',
bip32: {
public: 0x022d2533,
private: 0x0221312b
},
pubKeyHash: 0x1e,
scriptHash: 0x0d,
wif: 0xd4
};
bitcoinjs.bitcoin.networks.pivxtestnet = {
messagePrefix: 'unused',
bip32: {
public: 0x3a8061a0,
private: 0x3a805837
},
pubKeyHash: 0x8b,
scriptHash: 0x13,
wif: 0xef
};
</script>
<script>(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethUtil = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@@ -45714,7 +45786,7 @@ var time_estimates;time_estimates={estimate_attack_times:function(e){var t,n,s,o
},{}]},{},[4])(4)
});
//# sourceMappingURL=zxcvbn.js.map
</script>
<script>/*
* Detects entropy from a string.
@@ -46078,6 +46150,7 @@ window.Entropy = new (function() {
var showPubKey = true;
var showPrivKey = true;
var showQr = false;
var litecoinUseLtub = false;
var entropyChangeTimeoutEvent = null;
var phraseChangeTimeoutEvent = null;
@@ -46101,12 +46174,15 @@ window.Entropy = new (function() {
DOM.entropyWordCount = DOM.entropyContainer.find(".word-count");
DOM.entropyBinary = DOM.entropyContainer.find(".binary");
DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
DOM.phrase = $(".phrase");
DOM.passphrase = $(".passphrase");
DOM.generateContainer = $(".generate-container");
DOM.generate = $(".generate");
DOM.seed = $(".seed");
DOM.rootKey = $(".root-key");
DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
DOM.litecoinUseLtub = $(".litecoin-use-ltub");
DOM.extendedPrivKey = $(".extended-priv-key");
DOM.extendedPubKey = $(".extended-pub-key");
DOM.bip32tab = $("#bip32-tab");
@@ -46134,6 +46210,7 @@ window.Entropy = new (function() {
DOM.bip49change = $("#bip49 .change");
DOM.generatedStrength = $(".generate-container .strength");
DOM.hardenedAddresses = $(".hardened-addresses");
DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
DOM.addresses = $(".addresses");
DOM.rowsToAdd = $(".rows-to-add");
DOM.more = $(".more");
@@ -46162,6 +46239,7 @@ window.Entropy = new (function() {
DOM.generate.on("click", generateClicked);
DOM.more.on("click", showMore);
DOM.rootKey.on("input", delayedRootKeyChanged);
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
DOM.bip32path.on("input", calcForDerivationPath);
DOM.bip44account.on("input", calcForDerivationPath);
DOM.bip44change.on("input", calcForDerivationPath);
@@ -46169,6 +46247,7 @@ window.Entropy = new (function() {
DOM.bip49change.on("input", calcForDerivationPath);
DOM.tab.on("shown.bs.tab", calcForDerivationPath);
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);
@@ -46187,14 +46266,15 @@ window.Entropy = new (function() {
function networkChanged(e) {
clearDerivedKeys();
clearAddressesList();
DOM.litecoinLtubContainer.addClass("hidden");
var networkIndex = e.target.value;
var network = networks[networkIndex];
network.onSelect();
if (network.bip49available) {
showBip49();
if (network.p2wpkhNestedInP2shAvailable) {
showP2wpkhNestedInP2shAvailable();
}
else {
hideBip49();
showP2wpkhNestedInP2shUnavailable();
}
if (seed != null) {
phraseChanged();
@@ -46239,6 +46319,10 @@ window.Entropy = new (function() {
function delayedPhraseChanged() {
hideValidationError();
seed = null;
bip32RootKey = null;
bip32ExtendedKey = null;
clearAddressesList();
showPending();
if (phraseChangeTimeoutEvent != null) {
clearTimeout(phraseChangeTimeoutEvent);
@@ -46248,7 +46332,6 @@ window.Entropy = new (function() {
function phraseChanged() {
showPending();
hideValidationError();
setMnemonicLanguage();
// Get the mnemonic phrase
var phrase = DOM.phrase.val();
@@ -46261,7 +46344,6 @@ window.Entropy = new (function() {
var passphrase = DOM.passphrase.val();
calcBip32RootKeyFromSeed(phrase, passphrase);
calcForDerivationPath();
hidePending();
}
function delayedEntropyChanged() {
@@ -46324,7 +46406,6 @@ window.Entropy = new (function() {
function rootKeyChanged() {
showPending();
hideValidationError();
// Validate the root key TODO
var rootKeyBase58 = DOM.rootKey.val();
var errorText = validateRootKey(rootKeyBase58);
if (errorText) {
@@ -46336,11 +46417,21 @@ window.Entropy = new (function() {
calcForDerivationPath();
}
function litecoinUseLtubChanged() {
litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
if (litecoinUseLtub) {
network = bitcoinjs.bitcoin.networks.litecoinLtub;
}
else {
network = bitcoinjs.bitcoin.networks.litecoin;
}
phraseChanged();
}
function calcForDerivationPath() {
showPending();
clearDerivedKeys();
clearAddressesList();
hideValidationError();
showPending();
// Don't show bip49 if it's selected but network doesn't support it
if (bip49TabSelected() && !networkHasBip49()) {
return;
@@ -46360,7 +46451,6 @@ window.Entropy = new (function() {
displayBip49Info();
}
displayBip32Info();
hidePending();
}
function generateClicked() {
@@ -46508,7 +46598,7 @@ window.Entropy = new (function() {
function validateRootKey(rootKeyBase58) {
try {
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58);
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
}
catch (e) {
return "Invalid root key";
@@ -46596,7 +46686,9 @@ window.Entropy = new (function() {
return "No root key";
}
// Check no hardened derivation path when using xpub keys
var hardened = path.indexOf("'") > -1;
var hardenedPath = path.indexOf("'") > -1;
var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
var hardened = hardenedPath || hardenedAddresses;
var isXpubkey = bip32RootKey.isNeutered();
if (hardened && isXpubkey) {
return "Hardened derivation path is invalid with xpub key";
@@ -46667,23 +46759,25 @@ window.Entropy = new (function() {
for (var i=0; i<rows.length; i++) {
rows[i].shouldGenerate = false;
}
hidePending();
}
for (var i=0; i<total; i++) {
var index = i + start;
rows.push(new TableRow(index));
var isLast = i == total - 1;
rows.push(new TableRow(index, isLast));
}
})());
}
function TableRow(index) {
function TableRow(index, isLast) {
var self = this;
this.shouldGenerate = true;
var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
var isBip49 = bip49TabSelected();
var bip49available = networkHasBip49();
var isP2wpkhNestedInP2sh = bip49TabSelected() || (bip32TabSelected() && useP2wpkhNestedInP2sh());
var p2wpkhNestedInP2shAvailable = networkHasBip49();
function init() {
calculateValues();
@@ -46728,8 +46822,8 @@ window.Entropy = new (function() {
address = convertRippleAdrr(address);
}
// BIP49 addresses are different
if (isBip49) {
if (!bip49available) {
if (isP2wpkhNestedInP2sh) {
if (!p2wpkhNestedInP2shAvailable) {
return;
}
var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
@@ -46739,6 +46833,9 @@ window.Entropy = new (function() {
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
}
addAddressToList(indexText, address, pubkey, privkey);
if (isLast) {
hidePending();
}
}, 50)
}
@@ -47101,6 +47198,16 @@ window.Entropy = new (function() {
DOM.entropyWordCount.text(wordCount);
DOM.entropyBinary.text(entropy.binaryStr);
DOM.entropyBitsPerEvent.text(bitsPerEvent);
// detect and warn of filtering
var rawNoSpaces = DOM.entropy.val().replace(/\s/g, "");
var cleanNoSpaces = entropy.cleanStr.replace(/\s/g, "");
var isFiltered = rawNoSpaces.length != cleanNoSpaces.length;
if (isFiltered) {
DOM.entropyFilterWarning.removeClass('hidden');
}
else {
DOM.entropyFilterWarning.addClass('hidden');
}
}
function getEntropyTypeStr(entropy) {
@@ -47206,8 +47313,12 @@ window.Entropy = new (function() {
return DOM.bip32tab.hasClass("active");
}
function useP2wpkhNestedInP2sh() {
return DOM.useP2wpkhNestedInP2sh.prop("checked");
}
function networkHasBip49() {
return networks[DOM.network.val()].bip49available;
return networks[DOM.network.val()].p2wpkhNestedInP2shAvailable;
}
function bip49TabSelected() {
@@ -47219,20 +47330,23 @@ window.Entropy = new (function() {
DOM.bip49coin.val(coinValue);
}
function showBip49() {
function showP2wpkhNestedInP2shAvailable() {
DOM.bip49unavailable.addClass("hidden");
DOM.bip49available.removeClass("hidden");
DOM.useP2wpkhNestedInP2sh.prop("disabled", false);
}
function hideBip49() {
function showP2wpkhNestedInP2shUnavailable() {
DOM.bip49available.addClass("hidden");
DOM.bip49unavailable.removeClass("hidden");
DOM.useP2wpkhNestedInP2sh.prop("disabled", true);
DOM.useP2wpkhNestedInP2sh.prop("checked", false);
}
var networks = [
{
name: "BCH - Bitcoin Cash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(145);
@@ -47240,7 +47354,7 @@ window.Entropy = new (function() {
},
{
name: "BTC - Bitcoin",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(0);
@@ -47248,7 +47362,7 @@ window.Entropy = new (function() {
},
{
name: "BTC - Bitcoin Testnet",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.testnet;
setHdCoin(1);
@@ -47256,7 +47370,7 @@ window.Entropy = new (function() {
},
{
name: "CLAM - Clams",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.clam;
setHdCoin(23);
@@ -47264,7 +47378,7 @@ window.Entropy = new (function() {
},
{
name: "CRW - Crown",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.crown;
setHdCoin(72);
@@ -47272,7 +47386,7 @@ window.Entropy = new (function() {
},
{
name: "DASH - Dash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dash;
setHdCoin(5);
@@ -47280,7 +47394,7 @@ window.Entropy = new (function() {
},
{
name: "DASH - Dash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dashtn;
setHdCoin(1);
@@ -47288,7 +47402,7 @@ window.Entropy = new (function() {
},
{
name: "DOGE - Dogecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dogecoin;
setHdCoin(3);
@@ -47296,7 +47410,7 @@ window.Entropy = new (function() {
},
{
name: "ETH - Ethereum",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
@@ -47304,7 +47418,7 @@ window.Entropy = new (function() {
},
{
name: "GAME - GameCredits",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.game;
setHdCoin(101);
@@ -47312,7 +47426,7 @@ window.Entropy = new (function() {
},
{
name: "JBS - Jumbucks",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.jumbucks;
setHdCoin(26);
@@ -47320,23 +47434,49 @@ window.Entropy = new (function() {
},
{
name: "LTC - Litecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.litecoin;
setHdCoin(2);
DOM.litecoinLtubContainer.removeClass("hidden");
},
},
{
name: "MAZA - Maza",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.maza;
setHdCoin(13);
},
},
{
name: "NMC - Namecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.namecoin;
setHdCoin(7);
},
},
{
name: "PIVX - PIVX",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivx;
setHdCoin(119);
},
},
{
name: "PIVX - PIVX Testnet",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivxtestnet;
setHdCoin(1);
},
},
{
name: "PPC - Peercoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.peercoin;
setHdCoin(6);
@@ -47344,7 +47484,7 @@ window.Entropy = new (function() {
},
{
name: "SDC - ShadowCash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadow;
setHdCoin(35);
@@ -47352,7 +47492,7 @@ window.Entropy = new (function() {
},
{
name: "SDC - ShadowCash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadowtn;
setHdCoin(1);
@@ -47360,7 +47500,7 @@ window.Entropy = new (function() {
},
{
name: "SLM - Slimcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcoin;
setHdCoin(63);
@@ -47368,7 +47508,7 @@ window.Entropy = new (function() {
},
{
name: "SLM - Slimcoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcointn;
setHdCoin(111);
@@ -47376,7 +47516,7 @@ window.Entropy = new (function() {
},
{
name: "VIA - Viacoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacoin;
setHdCoin(14);
@@ -47384,7 +47524,7 @@ window.Entropy = new (function() {
},
{
name: "VIA - Viacoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacointestnet;
setHdCoin(1);
@@ -47392,7 +47532,7 @@ window.Entropy = new (function() {
},
{
name: "XMY - Myriadcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.myriadcoin;
setHdCoin(90);
@@ -47400,7 +47540,7 @@ window.Entropy = new (function() {
},
{
name: "XRP - Ripple",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(144);

View File

@@ -1,3 +1,34 @@
# 0.2.6
* Detect and warn when entropy is filtered / discarded
* Reword entropy text to indicate using a single source only
* Add BIP49 to More Info section
* Update compile script to work across python 2 and 3
* QR Codes use correctLevel 3 instead of 2
* Source map removed from zxcvbn
* Tidy up code with consistent use of commas and semicolons
# 0.2.5
* Rename variables for clarity between BIP49 and P2WPKH Nested In P2SH
* Fix bug for validation of root key when using non-bitcoin networks
* Add option to use P2WPKH Nested In P2SH addresses on BIP32 tab
# 0.2.4
* Show error when using xpub with hardened addresses
* Allow switching litecoin prefixes between xprv and Ltpv
# 0.2.3
* Add maza coin
# 0.2.2
* Improve showing feedback for pending calculations
* Bugfix: Clear old seed when mnemonic is changed
* Add PIVX network
# 0.2.1
* BTC is the default coin

View File

@@ -1,6 +1,7 @@
import os
import re
import datetime
from io import open
# This script generates the bip39-standalone.html file.

View File

@@ -55,7 +55,10 @@ at 1PC9aZC4hNX2rmmrt7uHTfYAS3hRbph4UN
Please do not make modifications to `bip39-standalone.html`, since they will
be overwritten by `compile.py`.
Make changes in `src/*` and apply them using the command `python compile.py`
Make changes in `src/*`.
Changes are applied during release using the command `python compile.py`, so
please do not commit changes to `bip39-standalone.html`
# Tests

View File

@@ -7,13 +7,17 @@ created with the following steps:
1. Run `python compile.py`
1. Commit these changes with message `Release vX.Y.Z`
1. Tag the commit `git tag X.Y.Z`
1. Push the changes `git push`
1. Push the new tag `git push --tags`
1. Get the hash of the file `sha256sum bip39-standalone.html`
1. Create the text for the release notes (see prior releases)
1. Sign the release notes `gpg --clearsign /tmp/releasenotes.txt`
1. Sign the release notes `gpg --clearsign /tmp/signature.txt`
1. Push the changes `git push`
1. Push the new tag `git push --tags`
1. Create a release on github from the tagged commit
1. include the signed release notes as text for the release
1. include the changelog for this release as text for the release
1. attach signature.txt.asc
1. attach the bip39-standalone.html file
1. Add a new post to twitter from @bip39tool with the version, link and hash
1. Publish to any hosted locations (eg iancoleman.github.io/bip39)
1. Download the file from the release and confirm it hashes to the expected value `sha256sum bip39-standalone.html`
1. Download the signature from the release and verify it. `gpg --verify signature.txt.asc`

View File

@@ -114,7 +114,7 @@
<div class="container">
<h1 class="text-center">Mnemonic Code Converter</h1>
<p class="version">v0.2.1</p>
<p class="version">v0.2.6</p>
<hr>
<div class="row">
<div class="col-md-12">
@@ -163,7 +163,14 @@
<div class="form-group">
<label for="entropy" class="col-sm-2 control-label" data-translate>Entropy</label>
<div class="col-sm-7">
<textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea>
<textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" data-translate-placeholder></textarea>
<div class="row filter-warning text-danger hidden">
<p class="col-sm-12">
<strong>
Some characters have been discarded
</strong>
</p>
</div>
<div class="row">
<label class="col-sm-3 control-label" data-translate><span class="more-info" data-translate-title title="Based on estimates from zxcvbn using Filtered Entropy">Time To Crack</span></label>
<div class="crack-time col-sm-3 form-control-static"></div>
@@ -266,6 +273,15 @@
<textarea id="root-key" class="root-key form-control" data-show-qr></textarea>
</div>
</div>
<div class="form-group litecoin-ltub-container hidden">
<label for="litecoin-use-ltub" class="col-sm-2 control-label" data-translate>Prefixes</label>
<div class="col-sm-10 checkbox">
<label>
<input type="checkbox" id="litecoin-use-ltub" class="litecoin-use-ltub">
Use <code>Ltpv / Ltub</code> instead of <code>xprv / xpub</code>
</label>
</div>
</div>
</form>
</div>
</div>
@@ -399,6 +415,13 @@
<span data-translate>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 data-translate>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" data-translate>Bitcoin Core</label>
<div class="col-sm-10">
@@ -617,6 +640,11 @@
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
</p>
<h3>BIP49 <span class="small" data-translate>Derivation scheme for P2WPKH-nested-in-P2SH based accounts</span></h3>
<p data-translate-html>
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki" target="_blank">official BIP49 spec</a>
</p>
<h3 data-translate>Private Keys</h3>
<p>
<span data-translate-html>

View File

@@ -9649,6 +9649,16 @@ module.exports = {
wif: 0xef
},
litecoin: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4,
},
pubKeyHash: 0x30,
scriptHash: 0x32,
wif: 0xb0
},
litecoinLtub: {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x019da462,
@@ -14827,4 +14837,4 @@ module.exports = {
}).call(this,require("buffer").Buffer)
},{"bs58check":80,"buffer":4}]},{},[33])(33)
});
});

View File

@@ -1,122 +1,133 @@
bitcoinjs.bitcoin.networks.shadow = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xEE80286A,
private: 0xEE8031E8
},
pubKeyHash: 0x3f,
scriptHash: 0x7d,
wif: 0xbf,
wif: 0xbf
};
bitcoinjs.bitcoin.networks.shadowtn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x76C0FDFB,
private: 0x76C1077A
},
pubKeyHash: 0x7f,
scriptHash: 0xc4,
wif: 0xff,
wif: 0xff
};
bitcoinjs.bitcoin.networks.clam = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xa8c26d64,
private: 0xa8c17826
},
pubKeyHash: 0x89,
scriptHash: 0x00, // TODO set this correctly
wif: 0x85,
wif: 0x85
};
bitcoinjs.bitcoin.networks.crown = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
wif: 0x80
};
bitcoinjs.bitcoin.networks.dash = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x4c,
scriptHash: 0x10,
wif: 0xcc,
wif: 0xcc
};
bitcoinjs.bitcoin.networks.maza = {
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x09,
wif: 0xe0
};
bitcoinjs.bitcoin.networks.dashtn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x8c,
scriptHash: 0x13,
wif: 0xef,
wif: 0xef
};
bitcoinjs.bitcoin.networks.game = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x26,
scriptHash: 0x05,
wif: 0xa6,
wif: 0xa6
};
bitcoinjs.bitcoin.networks.namecoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x34,
scriptHash: 0x00, // TODO set this correctly
wif: 0x80,
wif: 0x80
};
bitcoinjs.bitcoin.networks.peercoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x37,
scriptHash: 0x00, // TODO set this correctly
wif: 0xb7,
wif: 0xb7
};
bitcoinjs.bitcoin.networks.slimcoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0xef6adf10,
private: 0xef69ea80
},
pubKeyHash: 0x3f,
scriptHash: 0x7d,
wif: 0x46,
wif: 0x46
};
bitcoinjs.bitcoin.networks.slimcointn = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x043587CF,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0x57,
wif: 0x57
};
bitcoinjs.bitcoin.networks.dogecoin = {
@@ -127,8 +138,8 @@ bitcoinjs.bitcoin.networks.dogecoin = {
},
pubKeyHash: 0x1e,
scriptHash: 0x16,
wif: 0x9e,
},
wif: 0x9e
};
bitcoinjs.bitcoin.networks.viacoin = {
messagePrefix: '\x18Viacoin Signed Message:\n',
@@ -138,8 +149,8 @@ bitcoinjs.bitcoin.networks.viacoin = {
},
pubKeyHash: 0x47,
scriptHash: 0x21,
wif: 0xc7,
},
wif: 0xc7
};
bitcoinjs.bitcoin.networks.viacointestnet = {
messagePrefix: '\x18Viacoin Signed Message:\n',
@@ -149,8 +160,8 @@ bitcoinjs.bitcoin.networks.viacointestnet = {
},
pubKeyHash: 0x7f,
scriptHash: 0xc4,
wif: 0xff,
},
wif: 0xff
};
bitcoinjs.bitcoin.networks.gamerscoin = {
messagePrefix: '\x19Gamerscoin Signed Message:\n',
@@ -160,8 +171,8 @@ bitcoinjs.bitcoin.networks.gamerscoin = {
},
pubKeyHash: 0x26,
scriptHash: 0x05,
wif: 0xA6,
},
wif: 0xA6
};
bitcoinjs.bitcoin.networks.jumbucks = {
messagePrefix: '\x19Jumbucks Signed Message:\n',
@@ -171,8 +182,8 @@ bitcoinjs.bitcoin.networks.jumbucks = {
},
pubKeyHash: 0x2b,
scriptHash: 0x05,
wif: 0xab,
},
wif: 0xab
};
bitcoinjs.bitcoin.networks.zetacoin = {
messagePrefix: '\x18Zetacoin Signed Message:\n',
@@ -182,16 +193,38 @@ bitcoinjs.bitcoin.networks.zetacoin = {
},
pubKeyHash: 0x50,
scriptHash: 0x09,
wif: 0xe0,
}
wif: 0xe0
};
bitcoinjs.bitcoin.networks.myriadcoin = {
messagePrefix: "unused",
messagePrefix: 'unused',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x32,
scriptHash: 0x00, // TODO set this correctly
wif: 0xb2,
wif: 0xb2
};
bitcoinjs.bitcoin.networks.pivx = {
messagePrefix: 'unused',
bip32: {
public: 0x022d2533,
private: 0x0221312b
},
pubKeyHash: 0x1e,
scriptHash: 0x0d,
wif: 0xd4
};
bitcoinjs.bitcoin.networks.pivxtestnet = {
messagePrefix: 'unused',
bip32: {
public: 0x3a8061a0,
private: 0x3a805837
},
pubKeyHash: 0x8b,
scriptHash: 0x13,
wif: 0xef
};

View File

@@ -14,6 +14,7 @@
var showPubKey = true;
var showPrivKey = true;
var showQr = false;
var litecoinUseLtub = false;
var entropyChangeTimeoutEvent = null;
var phraseChangeTimeoutEvent = null;
@@ -37,12 +38,15 @@
DOM.entropyWordCount = DOM.entropyContainer.find(".word-count");
DOM.entropyBinary = DOM.entropyContainer.find(".binary");
DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
DOM.phrase = $(".phrase");
DOM.passphrase = $(".passphrase");
DOM.generateContainer = $(".generate-container");
DOM.generate = $(".generate");
DOM.seed = $(".seed");
DOM.rootKey = $(".root-key");
DOM.litecoinLtubContainer = $(".litecoin-ltub-container");
DOM.litecoinUseLtub = $(".litecoin-use-ltub");
DOM.extendedPrivKey = $(".extended-priv-key");
DOM.extendedPubKey = $(".extended-pub-key");
DOM.bip32tab = $("#bip32-tab");
@@ -70,6 +74,7 @@
DOM.bip49change = $("#bip49 .change");
DOM.generatedStrength = $(".generate-container .strength");
DOM.hardenedAddresses = $(".hardened-addresses");
DOM.useP2wpkhNestedInP2sh = $(".p2wpkh-nested-in-p2sh");
DOM.addresses = $(".addresses");
DOM.rowsToAdd = $(".rows-to-add");
DOM.more = $(".more");
@@ -98,6 +103,7 @@
DOM.generate.on("click", generateClicked);
DOM.more.on("click", showMore);
DOM.rootKey.on("input", delayedRootKeyChanged);
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
DOM.bip32path.on("input", calcForDerivationPath);
DOM.bip44account.on("input", calcForDerivationPath);
DOM.bip44change.on("input", calcForDerivationPath);
@@ -105,6 +111,7 @@
DOM.bip49change.on("input", calcForDerivationPath);
DOM.tab.on("shown.bs.tab", calcForDerivationPath);
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);
@@ -123,14 +130,15 @@
function networkChanged(e) {
clearDerivedKeys();
clearAddressesList();
DOM.litecoinLtubContainer.addClass("hidden");
var networkIndex = e.target.value;
var network = networks[networkIndex];
network.onSelect();
if (network.bip49available) {
showBip49();
if (network.p2wpkhNestedInP2shAvailable) {
showP2wpkhNestedInP2shAvailable();
}
else {
hideBip49();
showP2wpkhNestedInP2shUnavailable();
}
if (seed != null) {
phraseChanged();
@@ -175,6 +183,10 @@
function delayedPhraseChanged() {
hideValidationError();
seed = null;
bip32RootKey = null;
bip32ExtendedKey = null;
clearAddressesList();
showPending();
if (phraseChangeTimeoutEvent != null) {
clearTimeout(phraseChangeTimeoutEvent);
@@ -184,7 +196,6 @@
function phraseChanged() {
showPending();
hideValidationError();
setMnemonicLanguage();
// Get the mnemonic phrase
var phrase = DOM.phrase.val();
@@ -197,7 +208,6 @@
var passphrase = DOM.passphrase.val();
calcBip32RootKeyFromSeed(phrase, passphrase);
calcForDerivationPath();
hidePending();
}
function delayedEntropyChanged() {
@@ -260,7 +270,6 @@
function rootKeyChanged() {
showPending();
hideValidationError();
// Validate the root key TODO
var rootKeyBase58 = DOM.rootKey.val();
var errorText = validateRootKey(rootKeyBase58);
if (errorText) {
@@ -272,11 +281,21 @@
calcForDerivationPath();
}
function litecoinUseLtubChanged() {
litecoinUseLtub = DOM.litecoinUseLtub.prop("checked");
if (litecoinUseLtub) {
network = bitcoinjs.bitcoin.networks.litecoinLtub;
}
else {
network = bitcoinjs.bitcoin.networks.litecoin;
}
phraseChanged();
}
function calcForDerivationPath() {
showPending();
clearDerivedKeys();
clearAddressesList();
hideValidationError();
showPending();
// Don't show bip49 if it's selected but network doesn't support it
if (bip49TabSelected() && !networkHasBip49()) {
return;
@@ -296,7 +315,6 @@
displayBip49Info();
}
displayBip32Info();
hidePending();
}
function generateClicked() {
@@ -444,7 +462,7 @@
function validateRootKey(rootKeyBase58) {
try {
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58);
bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
}
catch (e) {
return "Invalid root key";
@@ -532,7 +550,9 @@
return "No root key";
}
// Check no hardened derivation path when using xpub keys
var hardened = path.indexOf("'") > -1;
var hardenedPath = path.indexOf("'") > -1;
var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
var hardened = hardenedPath || hardenedAddresses;
var isXpubkey = bip32RootKey.isNeutered();
if (hardened && isXpubkey) {
return "Hardened derivation path is invalid with xpub key";
@@ -603,23 +623,25 @@
for (var i=0; i<rows.length; i++) {
rows[i].shouldGenerate = false;
}
hidePending();
}
for (var i=0; i<total; i++) {
var index = i + start;
rows.push(new TableRow(index));
var isLast = i == total - 1;
rows.push(new TableRow(index, isLast));
}
})());
}
function TableRow(index) {
function TableRow(index, isLast) {
var self = this;
this.shouldGenerate = true;
var useHardenedAddresses = DOM.hardenedAddresses.prop("checked");
var isBip49 = bip49TabSelected();
var bip49available = networkHasBip49();
var isP2wpkhNestedInP2sh = bip49TabSelected() || (bip32TabSelected() && useP2wpkhNestedInP2sh());
var p2wpkhNestedInP2shAvailable = networkHasBip49();
function init() {
calculateValues();
@@ -664,8 +686,8 @@
address = convertRippleAdrr(address);
}
// BIP49 addresses are different
if (isBip49) {
if (!bip49available) {
if (isP2wpkhNestedInP2sh) {
if (!p2wpkhNestedInP2shAvailable) {
return;
}
var keyhash = bitcoinjs.bitcoin.crypto.hash160(key.getPublicKeyBuffer());
@@ -675,6 +697,9 @@
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
}
addAddressToList(indexText, address, pubkey, privkey);
if (isLast) {
hidePending();
}
}, 50)
}
@@ -1037,6 +1062,16 @@
DOM.entropyWordCount.text(wordCount);
DOM.entropyBinary.text(entropy.binaryStr);
DOM.entropyBitsPerEvent.text(bitsPerEvent);
// detect and warn of filtering
var rawNoSpaces = DOM.entropy.val().replace(/\s/g, "");
var cleanNoSpaces = entropy.cleanStr.replace(/\s/g, "");
var isFiltered = rawNoSpaces.length != cleanNoSpaces.length;
if (isFiltered) {
DOM.entropyFilterWarning.removeClass('hidden');
}
else {
DOM.entropyFilterWarning.addClass('hidden');
}
}
function getEntropyTypeStr(entropy) {
@@ -1142,8 +1177,12 @@
return DOM.bip32tab.hasClass("active");
}
function useP2wpkhNestedInP2sh() {
return DOM.useP2wpkhNestedInP2sh.prop("checked");
}
function networkHasBip49() {
return networks[DOM.network.val()].bip49available;
return networks[DOM.network.val()].p2wpkhNestedInP2shAvailable;
}
function bip49TabSelected() {
@@ -1155,20 +1194,23 @@
DOM.bip49coin.val(coinValue);
}
function showBip49() {
function showP2wpkhNestedInP2shAvailable() {
DOM.bip49unavailable.addClass("hidden");
DOM.bip49available.removeClass("hidden");
DOM.useP2wpkhNestedInP2sh.prop("disabled", false);
}
function hideBip49() {
function showP2wpkhNestedInP2shUnavailable() {
DOM.bip49available.addClass("hidden");
DOM.bip49unavailable.removeClass("hidden");
DOM.useP2wpkhNestedInP2sh.prop("disabled", true);
DOM.useP2wpkhNestedInP2sh.prop("checked", false);
}
var networks = [
{
name: "BCH - Bitcoin Cash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(145);
@@ -1176,7 +1218,7 @@
},
{
name: "BTC - Bitcoin",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(0);
@@ -1184,7 +1226,7 @@
},
{
name: "BTC - Bitcoin Testnet",
bip49available: true,
p2wpkhNestedInP2shAvailable: true,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.testnet;
setHdCoin(1);
@@ -1192,7 +1234,7 @@
},
{
name: "CLAM - Clams",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.clam;
setHdCoin(23);
@@ -1200,7 +1242,7 @@
},
{
name: "CRW - Crown",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.crown;
setHdCoin(72);
@@ -1208,7 +1250,7 @@
},
{
name: "DASH - Dash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dash;
setHdCoin(5);
@@ -1216,7 +1258,7 @@
},
{
name: "DASH - Dash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dashtn;
setHdCoin(1);
@@ -1224,7 +1266,7 @@
},
{
name: "DOGE - Dogecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.dogecoin;
setHdCoin(3);
@@ -1232,7 +1274,7 @@
},
{
name: "ETH - Ethereum",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(60);
@@ -1240,7 +1282,7 @@
},
{
name: "GAME - GameCredits",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.game;
setHdCoin(101);
@@ -1248,7 +1290,7 @@
},
{
name: "JBS - Jumbucks",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.jumbucks;
setHdCoin(26);
@@ -1256,23 +1298,49 @@
},
{
name: "LTC - Litecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.litecoin;
setHdCoin(2);
DOM.litecoinLtubContainer.removeClass("hidden");
},
},
{
name: "MAZA - Maza",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.maza;
setHdCoin(13);
},
},
{
name: "NMC - Namecoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.namecoin;
setHdCoin(7);
},
},
{
name: "PIVX - PIVX",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivx;
setHdCoin(119);
},
},
{
name: "PIVX - PIVX Testnet",
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.pivxtestnet;
setHdCoin(1);
},
},
{
name: "PPC - Peercoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.peercoin;
setHdCoin(6);
@@ -1280,7 +1348,7 @@
},
{
name: "SDC - ShadowCash",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadow;
setHdCoin(35);
@@ -1288,7 +1356,7 @@
},
{
name: "SDC - ShadowCash Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.shadowtn;
setHdCoin(1);
@@ -1296,7 +1364,7 @@
},
{
name: "SLM - Slimcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcoin;
setHdCoin(63);
@@ -1304,7 +1372,7 @@
},
{
name: "SLM - Slimcoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.slimcointn;
setHdCoin(111);
@@ -1312,7 +1380,7 @@
},
{
name: "VIA - Viacoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacoin;
setHdCoin(14);
@@ -1320,7 +1388,7 @@
},
{
name: "VIA - Viacoin Testnet",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.viacointestnet;
setHdCoin(1);
@@ -1328,7 +1396,7 @@
},
{
name: "XMY - Myriadcoin",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.myriadcoin;
setHdCoin(90);
@@ -1336,7 +1404,7 @@
},
{
name: "XRP - Ripple",
bip49available: false,
p2wpkhNestedInP2shAvailable: false,
onSelect: function() {
network = bitcoinjs.bitcoin.networks.bitcoin;
setHdCoin(144);

View File

@@ -23,6 +23,6 @@ this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(
55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,
45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];p.getRSBlocks=function(a,c){var d=p.getRsBlockTable(a,c);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+c);for(var b=d.length/3,e=[],f=0;f<b;f++)for(var h=d[3*f+0],g=d[3*f+1],j=d[3*f+2],l=0;l<h;l++)e.push(new p(g,j));return e};p.getRsBlockTable=function(a,c){switch(c){case 1:return p.RS_BLOCK_TABLE[4*(a-1)+0];case 0:return p.RS_BLOCK_TABLE[4*(a-1)+1];case 3:return p.RS_BLOCK_TABLE[4*
(a-1)+2];case 2:return p.RS_BLOCK_TABLE[4*(a-1)+3]}};t.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,c){for(var d=0;d<c;d++)this.putBit(1==(a>>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,
correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
correctLevel:3,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
j=Math.ceil((f+1)*b)-Math.floor(f*b);d.fillRect(Math.round(i*b),Math.round(f*e),g,j)}}else{a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();c=r("<table></table>").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e<a.getModuleCount();e++){f=r("<tr></tr>").css("height",b+"px").appendTo(c);for(i=0;i<a.getModuleCount();i++)r("<td></td>").css("width",
d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;$(a).appendTo(this)})}})($);

View File

@@ -25,4 +25,4 @@ var time_estimates;time_estimates={estimate_attack_times:function(e){var t,n,s,o
},{}]},{},[4])(4)
});
//# sourceMappingURL=zxcvbn.js.map

284
tests.js
View File

@@ -932,6 +932,96 @@ page.open(url, function(status) {
});
},
// Network can be set to pivx
function() {
page.open(url, function(status) {
// set the phrase and coin
var expected = "DBxgT7faCuno7jmtKuu6KWCiwqsVPqh1tS";
page.evaluate(function() {
$(".phrase").val("abandon abandon ability");
$(".phrase").trigger("input");
$(".network option[selected]").removeAttr("selected");
$(".network option").filter(function() {
return $(this).html() == "PIVX - PIVX";
}).prop("selected", true);
$(".network").trigger("change");
});
// check the address is generated correctly
waitForGenerate(function() {
var actual = page.evaluate(function() {
return $(".address:first").text();
});
if (actual != expected) {
console.log("PIVX address is incorrect");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
},
// Network can be set to pivx testnet
function() {
page.open(url, function(status) {
// set the phrase and coin
var expected = "yB5U384n6dGkVE3by5y9VdvHHPwPg68fQj";
page.evaluate(function() {
$(".phrase").val("abandon abandon ability");
$(".phrase").trigger("input");
$(".network option[selected]").removeAttr("selected");
$(".network option").filter(function() {
return $(this).html() == "PIVX - PIVX Testnet";
}).prop("selected", true);
$(".network").trigger("change");
});
// check the address is generated correctly
waitForGenerate(function() {
var actual = page.evaluate(function() {
return $(".address:first").text();
});
if (actual != expected) {
console.log("PIVX Testnet address is incorrect");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
},
// Network can be set to maza
function() {
page.open(url, function(status) {
// set the phrase and coin
var expected = "MGW4Bmi2NEm4PxSjgeFwhP9vg18JHoRnfw";
page.evaluate(function() {
$(".phrase").val("abandon abandon ability");
$(".phrase").trigger("input");
$(".network option[selected]").removeAttr("selected");
$(".network option").filter(function() {
return $(this).html() == "MAZA - Maza";
}).prop("selected", true);
$(".network").trigger("change");
});
// check the address is generated correctly
waitForGenerate(function() {
var actual = page.evaluate(function() {
return $(".address:first").text();
});
if (actual != expected) {
console.log("Maza address is incorrect");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
},
// BIP39 seed is set from phrase
function() {
page.open(url, function(status) {
@@ -4060,6 +4150,200 @@ page.open(url, function(status) {
});
},
// github issue 43
// Cleared mnemonic and root key still allows addresses to be generated
// https://github.com/iancoleman/bip39/issues/43
function() {
page.open(url, function(status) {
// set the phrase
page.evaluate(function() {
$("#bip49-tab a").click();
$(".phrase").val("abandon abandon ability");
$(".phrase").trigger("input");
});
waitForGenerate(function() {
// clear the mnemonic and root key
page.evaluate(function() {
$(".phrase").val("");
$(".phrase").trigger("input");
$(".root-key").val("");
$(".root-key").trigger("input");
$(".more").click();
});
waitForFeedback(function() {
// check there are no addresses shown
var addressCount = page.evaluate(function() {
return $(".address").length;
});
if (addressCount != 0) {
console.log("Clearing mnemonic should not allow addresses to be generated");
fail();
}
next();
});
});
});
},
// Github issue 95
// error trying to generate addresses from xpub with hardened derivation
function() {
page.open(url, function(status) {
// set the phrase
page.evaluate(function() {
// Use bip32 tab with hardened addresses
$(".hardened-addresses").prop("checked", true);
$("#bip32-tab a").click();
// set xpub for account 0 of bip44 for 'abandon abandon ability'
var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
$("#root-key").val(bip44AccountXpub);
$("#root-key").trigger("input");
});
waitForFeedback(function() {
// check the error message shows
var expected = "Hardened derivation path is invalid with xpub key";
var actual = page.evaluate(function() {
return $(".feedback").text();
});
if (actual != expected) {
console.log("xpub key with hardened addresses does not show feedback");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
},
// Litecoin uses xprv by default, and can optionally be set to ltpv
// github issue 96
// https://github.com/iancoleman/bip39/issues/96
// Issue with extended keys on Litecoin
function() {
page.open(url, function(status) {
// set the phrase and coin
page.evaluate(function() {
$(".phrase").val("abandon abandon ability");
$(".network option[selected]").removeAttr("selected");
$(".network option").filter(function() {
return $(this).html() == "LTC - Litecoin";
}).prop("selected", true);
$(".network").trigger("change");
$(".phrase").trigger("input");
});
// check the extended key is generated correctly
waitForGenerate(function() {
var expected = "xprv9s21ZrQH143K2jkGDCeTLgRewT9F2pH5JZs2zDmmjXes34geVnFiuNa8KTvY5WoYvdn4Ag6oYRoB6cXtc43NgJAEqDXf51xPm6fhiMCKwpi";
var actual = page.evaluate(function() {
return $(".root-key").val();
});
if (actual != expected) {
console.log("Litecoin root key does not default to xprv");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
// set litecoin to use ltub
page.evaluate(function() {
$(".addresses").empty();
$(".litecoin-use-ltub").prop("checked", true);
$(".litecoin-use-ltub").trigger("change");
});
waitForGenerate(function() {
var expected = "Ltpv71G8qDifUiNesiPqf6h5V6eQ8ic77oxQiYtawiACjBEx3sTXNR2HGDGnHETYxESjqkMLFBkKhWVq67ey1B2MKQXannUqNy1RZVHbmrEjnEU";
var actual = page.evaluate(function() {
return $(".root-key").val();
});
if (actual != expected) {
console.log("Litecoin root key cannot be set to use ltub");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
});
},
// 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?
function() {
page.open(url, function(status) {
// set the xpub and coin and select bip32 tab with p2wpkh addresses
page.evaluate(function() {
// use p2wpkh addresses
$(".p2wpkh-nested-in-p2sh").prop("checked", true);
// use bip32 tab
$("#bip32-tab a").click();
// use testnet
$(".network option[selected]").removeAttr("selected");
$(".network option").filter(function() {
return $(this).html() == "BTC - Bitcoin Testnet";
}).prop("selected", true);
$(".network").trigger("change");
// Set root xpub to BIP49 official test vector account 0
$(".root-key").val("tpubDD7tXK8KeQ3YY83yWq755fHY2JW8Ha8Q765tknUM5rSvjPcGWfUppDFMpQ1ScziKfW3ZNtZvAD7M3u7bSs7HofjTD3KP3YxPK7X6hwV8Rk2");
$(".root-key").trigger("input");
});
// check the address is generated correctly
waitForGenerate(function() {
var expected = "2Mww8dCYPUpKHofjgcXcBCEGmniw9CoaiD2";
var actual = page.evaluate(function() {
return $(".address:first").text();
});
if (actual != expected) {
console.log("BIP32 tab cannot generate P2WPKH Nested In P2SH addresses");
console.log("Expected: " + expected);
console.log("Actual: " + actual);
fail();
}
next();
});
});
},
// 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
// A warning is shown when entropy is filtered and discarded
function() {
page.open(url, function(status) {
// use entropy
page.evaluate(function() {
$(".use-entropy").prop("checked", true).trigger("change");
$(".entropy").val("00000000 00000000 00000000 00000000").trigger("input");
});
// check the filter warning does not show
waitForGenerate(function() {
var warningIsHidden = page.evaluate(function() {
return $(".entropy-container .filter-warning").hasClass("hidden");
});
if (!warningIsHidden) {
console.log("Entropy filter warning is showing when it should not");
fail();
}
page.evaluate(function() {
$(".entropy").val("10000000 zxcvbn 00000000 00000000 00000000").trigger("input");
});
// check the filter warning shows
waitForEntropyFeedback(function() {
var warningIsHidden = page.evaluate(function() {
return $(".entropy-container .filter-warning").hasClass("hidden");
});
if (warningIsHidden) {
console.log("Entropy filter warning is not showing when it should");
fail();
}
next();
});
});
});
},
// If you wish to add more tests, do so here...
// Here is a blank test template