mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-06 19:03:49 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa793f572f | ||
|
|
6973e692b0 | ||
|
|
22f8766947 | ||
|
|
8017442c50 | ||
|
|
82cf26c1cb | ||
|
|
206cbafceb | ||
|
|
9cf02dd452 | ||
|
|
f12242014d | ||
|
|
244c76022a | ||
|
|
516c16d721 | ||
|
|
f7e9fdf002 | ||
|
|
5c203fab6a | ||
|
|
40d542ba58 | ||
|
|
cc3c35487f |
11
changelog.md
11
changelog.md
@@ -1,3 +1,14 @@
|
||||
# 0.4.0
|
||||
|
||||
* Third party libraries deduplicated and minified
|
||||
* Add text reminder for multibit wallet change addresses
|
||||
* Seed field can be edited
|
||||
* Add bitcoin regtest parameters
|
||||
* Mnemonic conversion to entropy is hex encoded instead of binary
|
||||
* Entropy type can be manually selected
|
||||
* Add Bitcoin P2WSH and P2WSH-P2SH
|
||||
* Add Czech language
|
||||
|
||||
# 0.3.14
|
||||
|
||||
* Ethereum uses standard BIP44 as per majority of wallets (Issue 378)
|
||||
|
||||
105
libs/combined/index.js
Normal file
105
libs/combined/index.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/* base-x */
|
||||
|
||||
let basex = require('base-x')
|
||||
|
||||
/* bchaddrjs */
|
||||
|
||||
let bchaddr = require('bchaddrjs')
|
||||
|
||||
/* bchaddrjs slp */
|
||||
|
||||
let bchaddrSlp = require('bchaddrjs-slp')
|
||||
|
||||
/* biginteger */
|
||||
|
||||
let BigInteger = require('javascript-biginteger')
|
||||
|
||||
/* bitcoinjs-bip38 */
|
||||
|
||||
let bip38 = require('bip38')
|
||||
|
||||
/* bitcoinjs-lib */
|
||||
|
||||
let bitcoin = require('bitcoinjs-lib')
|
||||
|
||||
/* buffer */
|
||||
|
||||
let buffer = require('buffer');
|
||||
|
||||
/* elastos */
|
||||
// See https://github.com/iancoleman/bip39/pull/368
|
||||
// and https://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript/tree/iancoleman-bip39
|
||||
|
||||
let elastosjs = require('elastos-wallet-js')
|
||||
|
||||
/* ethereum-util */
|
||||
|
||||
let ethUtil = require('ethereumjs-util')
|
||||
|
||||
/* fast-levenshtein */
|
||||
|
||||
let levenshtein = require('fast-levenshtein')
|
||||
|
||||
/* groestlcoin */
|
||||
|
||||
let groestlcoinjs = require('groestlcoinjs-lib')
|
||||
|
||||
/* groestlcoin bip38 */
|
||||
|
||||
let groestlcoinjsBip38 = require('bip38grs')
|
||||
|
||||
/* kjua qr codes */
|
||||
|
||||
let kjua = require('kjua')
|
||||
|
||||
/* nebulas */
|
||||
|
||||
let nebulas = require('nebulas')
|
||||
|
||||
/* stellar-util */
|
||||
|
||||
let StellarBase = require('stellar-base');
|
||||
let edHd = require('ed25519-hd-key');
|
||||
let stellarUtil = {
|
||||
getKeypair: function (path, seed) {
|
||||
const result = edHd.derivePath(path, seed);
|
||||
return StellarBase.Keypair.fromRawEd25519Seed(result.key);
|
||||
},
|
||||
dummyNetwork: {
|
||||
bip32: {public: 0, private: 0},
|
||||
messagePrefix: '',
|
||||
pubKeyHash: 0,
|
||||
scriptHash: 0,
|
||||
wif: 0,
|
||||
},
|
||||
}
|
||||
|
||||
/* unorm */
|
||||
|
||||
let unorm = require('unorm')
|
||||
|
||||
/* zxcvbn */
|
||||
|
||||
let zxcvbn = require('zxcvbn')
|
||||
|
||||
/* exports */
|
||||
|
||||
module.exports = {
|
||||
basex,
|
||||
bchaddr,
|
||||
bchaddrSlp,
|
||||
buffer,
|
||||
BigInteger,
|
||||
bip38,
|
||||
bitcoin,
|
||||
elastosjs,
|
||||
ethUtil,
|
||||
groestlcoinjs,
|
||||
groestlcoinjsBip38,
|
||||
kjua,
|
||||
levenshtein,
|
||||
nebulas,
|
||||
stellarUtil,
|
||||
unorm,
|
||||
zxcvbn
|
||||
}
|
||||
17
libs/combined/npm-shrinkwrap.json
generated
Normal file
17
libs/combined/npm-shrinkwrap.json
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"elastos-wallet-js": {
|
||||
"version": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06",
|
||||
"dependencies": {
|
||||
"bitcore-lib-p256": {
|
||||
"version": "0.16.0",
|
||||
"dependencies": {
|
||||
"lodash": {
|
||||
"version": "4.17.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2241
libs/combined/package-lock.json
generated
Normal file
2241
libs/combined/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
libs/combined/package.json
Normal file
31
libs/combined/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "bip39-tool-external-libs",
|
||||
"version": "0.4.0",
|
||||
"scripts": {
|
||||
"build": "browserify index.js --standalone libs | uglifyjs -c > ../../src/js/bip39-libs.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"base-x": "3.0.7",
|
||||
"bchaddrjs": "0.4.4",
|
||||
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
||||
"bip38": "2.0.2",
|
||||
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
||||
"bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit",
|
||||
"buffer": "5.4.3",
|
||||
"ed25519-hd-key": "^1.0.0",
|
||||
"elastos-wallet-js": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06",
|
||||
"ethereumjs-util": "6.0.0",
|
||||
"fast-levenshtein": "2.0.6",
|
||||
"groestlcoinjs-lib": "git://github.com/Groestlcoin/groestlcoinjs-lib.git#3.3.2",
|
||||
"javascript-biginteger": "0.9.2",
|
||||
"kjua": "0.6.0",
|
||||
"nebulas": "0.5.6",
|
||||
"stellar-base": "^0.10.0",
|
||||
"unorm": "1.6.0",
|
||||
"zxcvbn": "4.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
}
|
||||
}
|
||||
6
libs/combined/readme.md
Normal file
6
libs/combined/readme.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Generate libs
|
||||
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
@@ -106,3 +106,6 @@ body {
|
||||
.visual-privacy .private-data {
|
||||
display: none;
|
||||
}
|
||||
.text-weight-normal {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.3.14</p>
|
||||
<p class="version">v0.4.0</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -123,12 +123,42 @@
|
||||
<div class="col-sm-3">
|
||||
<p>Valid entropy values include:</p>
|
||||
<ul>
|
||||
<li><strong>Binary</strong> [0-1]<br>101010011</li>
|
||||
<li><strong>Base 6</strong> [0-5]<br>123434014</li>
|
||||
<li><strong>Dice</strong> [1-6]<br>62535634</li>
|
||||
<li><strong>Base 10</strong> [0-9]<br>90834528</li>
|
||||
<li><strong>Hex</strong> [0-9A-F]<br>4187a8bfd9</li>
|
||||
<li><strong>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="binary">
|
||||
<strong>Binary</strong> [0-1]<br>101010011
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="base 6">
|
||||
<strong>Base 6</strong> [0-5]<br>123434014
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="dice">
|
||||
<strong>Dice</strong> [1-6]<br>62535634
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="base 10">
|
||||
<strong>Base 10</strong> [0-9]<br>90834528
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="hexadecimal" checked>
|
||||
<strong>Hex</strong> [0-9A-F]<br>4187a8bfd9
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" name="entropy-type" value="card">
|
||||
<strong>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -163,6 +193,7 @@
|
||||
<a href="#french" title="French">Français</a>
|
||||
<a href="#italian" title="Italian">Italiano</a>
|
||||
<a href="#korean" title="Korean">한국어</a>
|
||||
<a href="#czech" title="Czech">Čeština</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -190,7 +221,7 @@
|
||||
<div class="form-group">
|
||||
<label for="seed" class="col-sm-2 control-label">BIP39 Seed</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="seed" class="seed private-data form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
<textarea id="seed" class="seed private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -365,6 +396,7 @@
|
||||
<div class="col-sm-10">
|
||||
<p class="form-control no-border">
|
||||
<span>Use path <code>m/0'/0</code>.</span>
|
||||
<span>For change addresses use path <code>m/0'/1</code>.</span>
|
||||
</p>
|
||||
<p class="form-control no-border">
|
||||
<span>For more info see</span>
|
||||
@@ -508,6 +540,8 @@
|
||||
<select class="form-control bip141-semantics">
|
||||
<option value="p2wpkh">P2WPKH</option>
|
||||
<option value="p2wpkh-p2sh" selected>P2WPKH nested in P2SH</option>
|
||||
<option value="p2wsh">P2WSH (1-of-1 multisig)</option>
|
||||
<option value="p2wsh-p2sh">P2WSH nested in P2SH (1-of-1 multisig)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -923,25 +957,13 @@
|
||||
<td class="privkey private-data"><span data-show-qr></span></td>
|
||||
</tr>
|
||||
</script>
|
||||
<script src="js/polyfill.es6.js"></script>
|
||||
<script src="js/basex.js"></script>
|
||||
<script src="js/unorm.js"></script>
|
||||
<script src="js/jquery-3.2.1.js"></script>
|
||||
<script src="js/bootstrap-3.3.7.js"></script>
|
||||
<script src="js/levenshtein.js"></script>
|
||||
<script src="js/kjua-0.1.1.min.js"></script>
|
||||
<script src="js/bitcoinjs-3.3.2.js"></script>
|
||||
<script src="js/bip39-libs.js"></script>
|
||||
<script src="js/bitcoinjs-extensions.js"></script>
|
||||
<script src="js/bitcoinjs-bip38-2.0.2.js"></script>
|
||||
<script src="js/groestlcoinjs-3.3.2.js"></script>
|
||||
<script src="js/groestlcoinjs-bip38-2.0.2.js"></script>
|
||||
<script src="js/elastos-1.0.9.min.js"></script>
|
||||
<script src="js/segwit-parameters.js"></script>
|
||||
<script src="js/ethereumjs-util.js"></script>
|
||||
<script src="js/ripple-util.js"></script>
|
||||
<script src="js/casinocoin-util.js"></script>
|
||||
<script src="js/bchaddrjs-0.2.1.js"></script>
|
||||
<script src="js/nebulas-account.js"></script>
|
||||
<script src="js/eos-util.js"></script>
|
||||
<script src="js/sjcl-bip39.js"></script>
|
||||
<script src="js/wordlist_english.js"></script>
|
||||
@@ -952,11 +974,9 @@
|
||||
<script src="js/wordlist_french.js"></script>
|
||||
<script src="js/wordlist_italian.js"></script>
|
||||
<script src="js/wordlist_korean.js"></script>
|
||||
<script src="js/wordlist_czech.js"></script>
|
||||
<script src="js/jsbip39.js"></script>
|
||||
<script src="js/biginteger.js"></script>
|
||||
<script src="js/zxcvbn.js"></script>
|
||||
<script src="js/entropy.js"></script>
|
||||
<script src="js/stellar-util.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
2010
src/js/basex.js
2010
src/js/basex.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1620
src/js/biginteger.js
1620
src/js/biginteger.js
File diff suppressed because it is too large
Load Diff
1
src/js/bip39-libs.js
Normal file
1
src/js/bip39-libs.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
function convertCasinoCoinAdrr(address) {
|
||||
return window.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
return libs.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertCasinoCoinPriv(priv) {
|
||||
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
return libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
69
src/js/elastos-1.0.9.min.js
vendored
69
src/js/elastos-1.0.9.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@
|
||||
|
||||
window.Entropy = new (function() {
|
||||
|
||||
var TWO = new BigInteger(2);
|
||||
var TWO = new libs.BigInteger.BigInteger(2);
|
||||
|
||||
// matchers returns an array of the matched events for each type of entropy.
|
||||
// eg
|
||||
@@ -67,9 +67,9 @@ window.Entropy = new (function() {
|
||||
return ints;
|
||||
}
|
||||
|
||||
this.fromString = function(rawEntropyStr) {
|
||||
this.fromString = function(rawEntropyStr, baseStr) {
|
||||
// Find type of entropy being used (binary, hex, dice etc)
|
||||
var base = getBase(rawEntropyStr);
|
||||
var base = getBase(rawEntropyStr, baseStr);
|
||||
// Convert dice to base6 entropy (ie 1-6 to 0-5)
|
||||
// This is done by changing all 6s to 0s
|
||||
if (base.str == "dice") {
|
||||
@@ -103,11 +103,11 @@ window.Entropy = new (function() {
|
||||
// Convert base.ints to BigInteger.
|
||||
// Due to using unusual bases, eg cards of base52, this is not as simple as
|
||||
// using BigInteger.parse()
|
||||
var entropyInt = BigInteger.ZERO;
|
||||
var entropyInt = libs.BigInteger.BigInteger.ZERO;
|
||||
for (var i=base.ints.length-1; i>=0; i--) {
|
||||
var thisInt = BigInteger.parse(base.ints[i]);
|
||||
var thisInt = libs.BigInteger.BigInteger.parse(base.ints[i]);
|
||||
var power = (base.ints.length - 1) - i;
|
||||
var additionalEntropy = BigInteger.parse(base.asInt).pow(power).multiply(thisInt);
|
||||
var additionalEntropy = libs.BigInteger.BigInteger.parse(base.asInt).pow(power).multiply(thisInt);
|
||||
entropyInt = entropyInt.add(additionalEntropy);
|
||||
}
|
||||
// Convert entropy to binary
|
||||
@@ -166,13 +166,14 @@ window.Entropy = new (function() {
|
||||
return s;
|
||||
}
|
||||
|
||||
function getBase(str) {
|
||||
function getBase(str, baseStr) {
|
||||
// Need to get the lowest base for the supplied entropy.
|
||||
// This prevents interpreting, say, dice rolls as hexadecimal.
|
||||
var binaryMatches = matchers.binary(str);
|
||||
var hexMatches = matchers.hex(str);
|
||||
var autodetect = baseStr === undefined;
|
||||
// Find the lowest base that can be used, whilst ignoring any irrelevant chars
|
||||
if (binaryMatches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((binaryMatches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "binary") {
|
||||
var ints = binaryMatches.map(function(i) { return parseInt(i, 2) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -183,7 +184,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var cardMatches = matchers.card(str);
|
||||
if (cardMatches.length >= hexMatches.length / 2) {
|
||||
if ((cardMatches.length >= hexMatches.length / 2 && autodetect) || baseStr === "card") {
|
||||
var ints = convertCardsToInts(cardMatches);
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -194,7 +195,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var diceMatches = matchers.dice(str);
|
||||
if (diceMatches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((diceMatches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "dice") {
|
||||
var ints = diceMatches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -205,7 +206,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var base6Matches = matchers.base6(str);
|
||||
if (base6Matches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((base6Matches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "base 6") {
|
||||
var ints = base6Matches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -216,7 +217,7 @@ window.Entropy = new (function() {
|
||||
}
|
||||
}
|
||||
var base10Matches = matchers.base10(str);
|
||||
if (base10Matches.length == hexMatches.length && hexMatches.length > 0) {
|
||||
if ((base10Matches.length == hexMatches.length && hexMatches.length > 0 && autodetect) || baseStr === "base 10") {
|
||||
var ints = base10Matches.map(function(i) { return parseInt(i) });
|
||||
return {
|
||||
ints: ints,
|
||||
@@ -327,7 +328,7 @@ window.Entropy = new (function() {
|
||||
// Math.LOG2E
|
||||
// log2(8) gave 2.9999999999999996 which when floored causes issues.
|
||||
// So instead use the BigInteger library to get it right.
|
||||
return BigInteger.log(x) / BigInteger.log(2);
|
||||
return libs.BigInteger.BigInteger.log(x) / libs.BigInteger.BigInteger.log(2);
|
||||
};
|
||||
|
||||
// Depends on BigInteger
|
||||
@@ -335,9 +336,9 @@ window.Entropy = new (function() {
|
||||
if (n == 0) {
|
||||
return 1;
|
||||
}
|
||||
f = BigInteger.ONE;
|
||||
f = libs.BigInteger.BigInteger.ONE;
|
||||
for (var i=1; i<=n; i++) {
|
||||
f = f.multiply(new BigInteger(i));
|
||||
f = f.multiply(new libs.BigInteger.BigInteger(i));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
614
src/js/index.js
614
src/js/index.js
File diff suppressed because it is too large
Load Diff
2
src/js/kjua-0.1.1.min.js
vendored
2
src/js/kjua-0.1.1.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,138 +0,0 @@
|
||||
// source
|
||||
// https://github.com/hiddentao/fast-levenshtein/blob/2.0.6/levenshtein.js
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var collator;
|
||||
try {
|
||||
collator = (typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined") ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
||||
} catch (err){
|
||||
console.log("Collator could not be initialized and wouldn't be used");
|
||||
}
|
||||
// arrays to re-use
|
||||
var prevRow = [],
|
||||
str2Char = [];
|
||||
|
||||
/**
|
||||
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
|
||||
*/
|
||||
var Levenshtein = {
|
||||
/**
|
||||
* Calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @param [options] Additional options.
|
||||
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
||||
* @return Integer the levenshtein distance (0 and above).
|
||||
*/
|
||||
get: function(str1, str2, options) {
|
||||
var useCollator = (options && collator && options.useCollator);
|
||||
|
||||
var str1Len = str1.length,
|
||||
str2Len = str2.length;
|
||||
|
||||
// base cases
|
||||
if (str1Len === 0) return str2Len;
|
||||
if (str2Len === 0) return str1Len;
|
||||
|
||||
// two rows
|
||||
var curCol, nextCol, i, j, tmp;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<str2Len; ++i) {
|
||||
prevRow[i] = i;
|
||||
str2Char[i] = str2.charCodeAt(i);
|
||||
}
|
||||
prevRow[str2Len] = str2Len;
|
||||
|
||||
var strCmp;
|
||||
if (useCollator) {
|
||||
// calculate current row distance from previous row using collator
|
||||
for (i = 0; i < str1Len; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j = 0; j < str2Len; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
|
||||
|
||||
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
||||
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
}
|
||||
|
||||
// copy last col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// calculate current row distance from previous row without collator
|
||||
for (i = 0; i < str1Len; ++i) {
|
||||
nextCol = i + 1;
|
||||
|
||||
for (j = 0; j < str2Len; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
strCmp = str1.charCodeAt(i) === str2Char[j];
|
||||
|
||||
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
||||
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
}
|
||||
|
||||
// copy last col value into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
}
|
||||
}
|
||||
return nextCol;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// amd
|
||||
if (typeof define !== "undefined" && define !== null && define.amd) {
|
||||
define(function() {
|
||||
return Levenshtein;
|
||||
});
|
||||
}
|
||||
// commonjs
|
||||
else if (typeof module !== "undefined" && module !== null && typeof exports !== "undefined" && module.exports === exports) {
|
||||
module.exports = Levenshtein;
|
||||
}
|
||||
// web worker
|
||||
else if (typeof self !== "undefined" && typeof self.postMessage === 'function' && typeof self.importScripts === 'function') {
|
||||
self.Levenshtein = Levenshtein;
|
||||
}
|
||||
// browser main thread
|
||||
else if (typeof window !== "undefined" && window !== null) {
|
||||
window.Levenshtein = Levenshtein;
|
||||
}
|
||||
}());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
function convertRippleAdrr(address) {
|
||||
return window.basex('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
return libs.basex('rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertRipplePriv(priv) {
|
||||
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
return libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// p2wpkh
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
libs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -15,7 +15,7 @@ bitcoinjs.bitcoin.networks.bitcoin.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.testnet.p2wpkh = {
|
||||
libs.bitcoin.networks.testnet.p2wpkh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
@@ -28,9 +28,22 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wpkh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wpkh in p2sh
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -43,7 +56,7 @@ bitcoinjs.bitcoin.networks.bitcoin.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
@@ -56,7 +69,102 @@ bitcoinjs.bitcoin.networks.testnet.p2wpkhInP2sh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecoin.p2wpkh = {
|
||||
libs.bitcoin.networks.regtest.p2wpkhInP2sh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x044a5262,
|
||||
private: 0x044a4e28
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wsh
|
||||
|
||||
libs.bitcoin.networks.bitcoin.p2wsh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x02aa7ed3,
|
||||
private: 0x02aa7a99
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.testnet.p2wsh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
bip32: {
|
||||
public: 0x02575483,
|
||||
private: 0x02575048
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wsh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x02575483,
|
||||
private: 0x02575048
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// p2wsh in p2sh
|
||||
|
||||
libs.bitcoin.networks.bitcoin.p2wshInP2sh = {
|
||||
baseNetwork: "bitcoin",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0295b43f,
|
||||
private: 0x0295b005
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.testnet.p2wshInP2sh = {
|
||||
baseNetwork: "testnet",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'tb',
|
||||
bip32: {
|
||||
public: 0x024289ef,
|
||||
private: 0x024285b5
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.regtest.p2wshInP2sh = {
|
||||
baseNetwork: "regtest",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'bcrt',
|
||||
bip32: {
|
||||
public: 0x024289ef,
|
||||
private: 0x024285b5
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.litecoin.p2wpkh = {
|
||||
baseNetwork: "litecoin",
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bech32: 'ltc',
|
||||
@@ -69,7 +177,7 @@ bitcoinjs.bitcoin.networks.litecoin.p2wpkh = {
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "litecoin",
|
||||
messagePrefix: '\x19Litecoin Signed Message:\n',
|
||||
bech32: 'ltc',
|
||||
@@ -82,7 +190,7 @@ bitcoinjs.bitcoin.networks.litecoin.p2wpkhInP2sh = {
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
libs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
baseNetwork: "fujicoin",
|
||||
messagePrefix: '\x19FujiCoin Signed Message:\n',
|
||||
bech32: 'fc',
|
||||
@@ -95,7 +203,7 @@ bitcoinjs.bitcoin.networks.fujicoin.p2wpkh = {
|
||||
wif: 0xa4
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "fujicoin",
|
||||
messagePrefix: '\x19FujiCoin Signed Message:\n',
|
||||
bech32: 'fc',
|
||||
@@ -108,7 +216,7 @@ bitcoinjs.bitcoin.networks.fujicoin.p2wpkhInP2sh = {
|
||||
wif: 0xa4
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.vertcoin.p2wpkh = {
|
||||
libs.bitcoin.networks.vertcoin.p2wpkh = {
|
||||
baseNetwork: "vertcoin",
|
||||
messagePrefix: '\x18Vertcoin Signed Message:\n',
|
||||
bech32: 'vtc',
|
||||
@@ -121,7 +229,7 @@ bitcoinjs.bitcoin.networks.vertcoin.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.vertcoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.vertcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "vertcoin",
|
||||
messagePrefix: '\x18Vertcoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -133,7 +241,7 @@ bitcoinjs.bitcoin.networks.vertcoin.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bgold.p2wpkh = {
|
||||
libs.bitcoin.networks.bgold.p2wpkh = {
|
||||
baseNetwork: "bgold",
|
||||
messagePrefix: '\x1DBitcoin Gold Signed Message:\n',
|
||||
bech32: 'btg',
|
||||
@@ -146,7 +254,7 @@ bitcoinjs.bitcoin.networks.bgold.p2wpkh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bgold.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.bgold.p2wpkhInP2sh = {
|
||||
baseNetwork: "bgold",
|
||||
messagePrefix: '\x1DBitcoin Gold Signed Message:\n',
|
||||
bech32: 'btg',
|
||||
@@ -159,7 +267,7 @@ bitcoinjs.bitcoin.networks.bgold.p2wpkhInP2sh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
libs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: 'x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
@@ -172,7 +280,7 @@ bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: '\x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
@@ -185,7 +293,7 @@ bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blockstamp.p2wpkh = {
|
||||
libs.bitcoin.networks.blockstamp.p2wpkh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -198,7 +306,7 @@ bitcoinjs.bitcoin.networks.blockstamp.p2wpkh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
@@ -211,7 +319,7 @@ bitcoinjs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.nix.p2wpkh = {
|
||||
libs.bitcoin.networks.nix.p2wpkh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
@@ -224,7 +332,7 @@ bitcoinjs.bitcoin.networks.nix.p2wpkh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.nix.p2wpkhInP2sh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
@@ -237,7 +345,7 @@ bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.cpuchain.p2wpkh = {
|
||||
libs.bitcoin.networks.cpuchain.p2wpkh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
@@ -250,7 +358,7 @@ bitcoinjs.bitcoin.networks.cpuchain.p2wpkh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
@@ -263,7 +371,7 @@ bitcoinjs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkh = {
|
||||
libs.bitcoin.networks.monkeyproject.p2wpkh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
@@ -276,7 +384,7 @@ bitcoinjs.bitcoin.networks.monkeyproject.p2wpkh = {
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
@@ -289,7 +397,7 @@ bitcoinjs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.atom.p2wpkh = {
|
||||
libs.bitcoin.networks.atom.p2wpkh = {
|
||||
baseNetwork: "atom",
|
||||
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
|
||||
bech32: 'atom',
|
||||
@@ -302,7 +410,7 @@ bitcoinjs.bitcoin.networks.atom.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.atom.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.atom.p2wpkhInP2sh = {
|
||||
baseNetwork: "atom",
|
||||
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
|
||||
bech32: 'atom',
|
||||
@@ -315,7 +423,7 @@ bitcoinjs.bitcoin.networks.atom.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcore.p2wpkh = {
|
||||
libs.bitcoin.networks.bitcore.p2wpkh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
@@ -328,7 +436,7 @@ bitcoinjs.bitcoin.networks.bitcore.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
@@ -341,7 +449,7 @@ bitcoinjs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
libs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
@@ -354,7 +462,7 @@ bitcoinjs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
@@ -367,7 +475,7 @@ bitcoinjs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.syscoin.p2wpkh = {
|
||||
libs.bitcoin.networks.syscoin.p2wpkh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
@@ -380,7 +488,7 @@ bitcoinjs.bitcoin.networks.syscoin.p2wpkh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
@@ -393,7 +501,7 @@ bitcoinjs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.viacoin.p2wpkh = {
|
||||
libs.bitcoin.networks.viacoin.p2wpkh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
@@ -406,7 +514,7 @@ bitcoinjs.bitcoin.networks.viacoin.p2wpkh = {
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
@@ -419,7 +527,7 @@ bitcoinjs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
@@ -432,7 +540,7 @@ bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
@@ -445,7 +553,7 @@ bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
@@ -458,7 +566,7 @@ bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
@@ -471,7 +579,7 @@ bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkh = {
|
||||
libs.bitcoin.networks.litecointestnet.p2wpkh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
@@ -484,7 +592,7 @@ bitcoinjs.bitcoin.networks.litecointestnet.p2wpkh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
@@ -497,7 +605,7 @@ bitcoinjs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
|
||||
libs.bitcoin.networks.groestlcoin.p2wpkh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
@@ -510,7 +618,7 @@ bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkh = {
|
||||
libs.bitcoin.networks.groestlcointestnet.p2wpkh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
@@ -523,7 +631,7 @@ bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
@@ -536,7 +644,7 @@ bitcoinjs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
|
||||
42516
src/js/stellar-util.js
42516
src/js/stellar-util.js
File diff suppressed because one or more lines are too long
445
src/js/unorm.js
445
src/js/unorm.js
File diff suppressed because one or more lines are too long
14
src/js/wordlist_czech.js
Normal file
14
src/js/wordlist_czech.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -412,6 +412,13 @@ it('Allows selection of bitcoin testnet', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of bitcoin regtest', function(done) {
|
||||
var params = {
|
||||
selectText: "BTC - Bitcoin RegTest",
|
||||
firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of litecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "LTC - Litecoin",
|
||||
@@ -2002,11 +2009,7 @@ it('Allows the user to set the BIP32 root key', function(done) {
|
||||
});
|
||||
|
||||
// Setting BIP32 root key clears the existing phrase, passphrase and seed
|
||||
// TODO this doesn't work in selenium with chrome
|
||||
it('Confirms the existing phrase should be cleared', function(done) {
|
||||
if (browser == "chrome") {
|
||||
pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
|
||||
}
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('A non-blank but invalid value');
|
||||
driver.findElement(By.css('.root-key'))
|
||||
@@ -2020,11 +2023,7 @@ it('Confirms the existing phrase should be cleared', function(done) {
|
||||
});
|
||||
|
||||
// Clearing of phrase, passphrase and seed can be cancelled by user
|
||||
// TODO this doesn't work in selenium with chrome
|
||||
it('Allows the clearing of the phrase to be cancelled', function(done) {
|
||||
if (browser == "chrome") {
|
||||
pending("Selenium + Chrome headless bug for alert, see https://stackoverflow.com/q/45242264");
|
||||
}
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('abandon abandon ability');
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
@@ -3694,6 +3693,106 @@ it('Can generate BIP141 addresses with P2WPKH-in-P2SH semanitcs', function(done)
|
||||
});
|
||||
});
|
||||
|
||||
it('Can generate BIP141 addresses with P2WSH semanitcs', function(done) {
|
||||
driver.findElement(By.css('#bip141-tab a'))
|
||||
.click();
|
||||
// Choose P2WSH
|
||||
driver.executeScript(function() {
|
||||
$(".bip141-semantics option[selected]").removeAttr("selected");
|
||||
$(".bip141-semantics option").filter(function(i,e) {
|
||||
return $(e).html() == "P2WSH (1-of-1 multisig)";
|
||||
}).prop("selected", true);
|
||||
$(".bip141-semantics").trigger("change");
|
||||
});
|
||||
driver.findElement(By.css(".phrase"))
|
||||
.sendKeys("abandon abandon ability");
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css("#root-key"))
|
||||
.getAttribute("value")
|
||||
.then(function(rootKey) {
|
||||
expect(rootKey).toBe("ZprvAhadJRUYsNge9uHspaggavxU1BUQ8QwfT4Z9UGq5sKF2mSt1mVy8EckLAaoBdmLHyP5eYDJ3LxtmzMNnLg2MRFe7QN2ueF4NCH4s5PrCDR6");
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe("bc1q2qhee847pv438tgg8hc7mjy38n8dklleshettn344l0tgs0kj5hskz9p9r");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('Can generate BIP141 addresses with P2WSH-in-P2SH semanitcs', function(done) {
|
||||
driver.findElement(By.css('#bip141-tab a'))
|
||||
.click();
|
||||
// Choose P2WSH-in-P2SH
|
||||
driver.executeScript(function() {
|
||||
$(".bip141-semantics option[selected]").removeAttr("selected");
|
||||
$(".bip141-semantics option").filter(function(i,e) {
|
||||
return $(e).html() == "P2WSH nested in P2SH (1-of-1 multisig)";
|
||||
}).prop("selected", true);
|
||||
$(".bip141-semantics").trigger("change");
|
||||
});
|
||||
driver.findElement(By.css(".phrase"))
|
||||
.sendKeys("abandon abandon ability");
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css("#root-key"))
|
||||
.getAttribute("value")
|
||||
.then(function(rootKey) {
|
||||
expect(rootKey).toBe("YprvANkMzkodih9AJc6kzDu4NqrxqDKxBnxAXx2vgswCVJs9iM4nWqoZcZ6C9NqbdrgNZjxqnjhUtJYE74mDcycLd1xWY2LV4LEsvZ1DgqxuAKe");
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe("343DLC4vGDyHBbBr9myL8zzZA1MdN9TM1G");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('Uses Vprv for bitcoin testnet p2wsh', function(done) {
|
||||
selectNetwork("BTC - Bitcoin Testnet");
|
||||
driver.findElement(By.css('#bip141-tab a'))
|
||||
.click()
|
||||
// Choose P2WSH
|
||||
driver.executeScript(function() {
|
||||
$(".bip141-semantics option[selected]").removeAttr("selected");
|
||||
$(".bip141-semantics option").filter(function(i,e) {
|
||||
return $(e).html() == "P2WSH (1-of-1 multisig)";
|
||||
}).prop("selected", true);
|
||||
$(".bip141-semantics").trigger("change");
|
||||
});
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('abandon abandon ability');
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css('.root-key'))
|
||||
.getAttribute("value")
|
||||
.then(function(path) {
|
||||
expect(path).toBe("Vprv16YtLrHXxePM5ja5hXQbiJs5JKDAc4WcaXo5rZcrVMU6bMhUg1oY7fpPku3i819gvMcHvq1h8aELDsyfCEs19vj1Q3iDHRrESWyJConkoT1");
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('Uses Uprv for bitcoin testnet p2wsh-in-p2sh', function(done) {
|
||||
selectNetwork("BTC - Bitcoin Testnet");
|
||||
driver.findElement(By.css('#bip141-tab a'))
|
||||
.click()
|
||||
// Choose P2WSH-in-P2SH
|
||||
driver.executeScript(function() {
|
||||
$(".bip141-semantics option[selected]").removeAttr("selected");
|
||||
$(".bip141-semantics option").filter(function(i,e) {
|
||||
return $(e).html() == "P2WSH nested in P2SH (1-of-1 multisig)";
|
||||
}).prop("selected", true);
|
||||
$(".bip141-semantics").trigger("change");
|
||||
});
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('abandon abandon ability');
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css('.root-key'))
|
||||
.getAttribute("value")
|
||||
.then(function(path) {
|
||||
expect(path).toBe("Uprv95RJn67y7xyEuRLHenkZYVUx9LkARJzAsVx3ZJMeyHMdVwosWD9K8JTe4Z1FeE4gwBVcnqKF3f82ZvJxkBxHS5E74fYnigxvqeke8ZV3Fp2");
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('Can generate BIP141 addresses with P2WPKH semanitcs', function(done) {
|
||||
// This result tested against bitcoinjs-lib test spec for segwit address
|
||||
// using the first private key of this mnemonic and default path m/0
|
||||
@@ -4143,7 +4242,7 @@ it('Converts mnemonics into raw entropy', function(done) {
|
||||
driver.findElement(By.css('.entropy'))
|
||||
.getAttribute("value")
|
||||
.then(function(entropy) {
|
||||
expect(entropy).toBe("00000000000000000000000000000001");
|
||||
expect(entropy).toBe("00000001");
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.getAttribute("value")
|
||||
.then(function(phrase) {
|
||||
@@ -4185,4 +4284,61 @@ it('Shows split prase cards', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
// It allows manually specifying the entropy type
|
||||
it('Allows entropy type to be manually selected', function(done) {
|
||||
driver.findElement(By.css('.use-entropy'))
|
||||
.click();
|
||||
// use decimal entropy
|
||||
driver.findElement(By.css('.entropy'))
|
||||
.sendKeys("91");
|
||||
// manually change to binary entropy
|
||||
driver.executeScript(function() {
|
||||
$(".entropy-container input[value='binary']").click();
|
||||
});
|
||||
driver.sleep(entropyFeedbackDelay).then(function() {
|
||||
driver.findElement(By.css('.entropy-container'))
|
||||
.getText()
|
||||
.then(function(text) {
|
||||
// overide 91 to be just 1
|
||||
var key = "Filtered Entropy";
|
||||
var value = "1";
|
||||
var reText = key + "\\s+" + value;
|
||||
var re = new RegExp(reText);
|
||||
expect(text).toMatch(re);
|
||||
// overide automatic decimal to binary
|
||||
var key = "Entropy Type";
|
||||
var value = "binary";
|
||||
var reText = key + "\\s+" + value;
|
||||
var re = new RegExp(reText);
|
||||
expect(text).toMatch(re);
|
||||
// overide 2 events to 1
|
||||
var key = "Event Count";
|
||||
var value = 1;
|
||||
var reText = key + "\\s+" + value;
|
||||
var re = new RegExp(reText);
|
||||
expect(text).toMatch(re);
|
||||
// overide log2(10)*2 bits to 1 bit
|
||||
var key = "Total Bits";
|
||||
var value = 1;
|
||||
var reText = key + "\\s+" + value;
|
||||
var re = new RegExp(reText);
|
||||
expect(text).toMatch(re);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// https://github.com/iancoleman/bip39/issues/388
|
||||
// Make field for bip39 seed editable
|
||||
it('Generates addresses when seed is set', function(done) {
|
||||
driver.findElement(By.css('.seed'))
|
||||
.sendKeys("20da140d3dd1df8713cefcc4d54ce0e445b4151027a1ab567b832f6da5fcc5afc1c3a3f199ab78b8e0ab4652efd7f414ac2c9a3b81bceb879a70f377aa0a58f3");
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe("1Di3Vp7tBWtyQaDABLAjfWtF6V7hYKJtug");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user