mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-06 19:03:49 +00:00
Compare commits
185 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76531b610a | ||
|
|
c845ee6f6e | ||
|
|
c394ec3c4f | ||
|
|
55367b989e | ||
|
|
732613e44c | ||
|
|
9ce31d3509 | ||
|
|
f8fae68efb | ||
|
|
93f3a286db | ||
|
|
3799728c76 | ||
|
|
b130271b2b | ||
|
|
ea2cb91a49 | ||
|
|
bfe1963eaa | ||
|
|
a04946e23e | ||
|
|
700294714c | ||
|
|
d93f2ba9f0 | ||
|
|
96ee8ab0a0 | ||
|
|
659b06a7b8 | ||
|
|
653538cd3a | ||
|
|
1ba5816184 | ||
|
|
0a23f51792 | ||
|
|
b9b3eaf670 | ||
|
|
7b29420f1a | ||
|
|
909297015e | ||
|
|
c7a092db32 | ||
|
|
de5fe245cc | ||
|
|
4dc041d77e | ||
|
|
7cfd04e318 | ||
|
|
d0428a8d21 | ||
|
|
3dbf117928 | ||
|
|
342ff964aa | ||
|
|
75138beed9 | ||
|
|
36523e0d97 | ||
|
|
44e705cd31 | ||
|
|
3e2af09e07 | ||
|
|
907172d6f0 | ||
|
|
394bce7c9e | ||
|
|
bc32c84166 | ||
|
|
76120cb0b4 | ||
|
|
385ee32fd4 | ||
|
|
5b689bd6e7 | ||
|
|
ac537983d9 | ||
|
|
5b2edb3998 | ||
|
|
eee4a60b35 | ||
|
|
dedb054fd8 | ||
|
|
079635cba1 | ||
|
|
5db3540e89 | ||
|
|
b502adc910 | ||
|
|
cab37a96c4 | ||
|
|
b603572295 | ||
|
|
8817e2487a | ||
|
|
c6c86591a9 | ||
|
|
5d1bb7d776 | ||
|
|
ea96c345cc | ||
|
|
318ec4dc9f | ||
|
|
ec38b3a263 | ||
|
|
9cec5dd2b7 | ||
|
|
31264e8bea | ||
|
|
e440d504fb | ||
|
|
786cd442cd | ||
|
|
9f675f2e47 | ||
|
|
e5c4aa4098 | ||
|
|
45e40c288f | ||
|
|
519e9dc728 | ||
|
|
67f18e2a63 | ||
|
|
c4f4208b95 | ||
|
|
881fbe2234 | ||
|
|
c7a1a00040 | ||
|
|
6aa2c1d26d | ||
|
|
9e836ac8e6 | ||
|
|
e2186682ac | ||
|
|
152f0ce966 | ||
|
|
084ff40d4f | ||
|
|
b244e34403 | ||
|
|
e33f4b2704 | ||
|
|
6c733477db | ||
|
|
a36c509c91 | ||
|
|
7d4e4cbe26 | ||
|
|
82e3938afe | ||
|
|
06cd4e7608 | ||
|
|
8b569deeae | ||
|
|
ad59508d7c | ||
|
|
562ece8004 | ||
|
|
8e3b890d26 | ||
|
|
6f53a445ee | ||
|
|
858c29e3be | ||
|
|
5a085aed79 | ||
|
|
7d68d5474e | ||
|
|
21e2e6c951 | ||
|
|
7f59c88dbc | ||
|
|
b85da0745a | ||
|
|
0ae59396f5 | ||
|
|
3451d1a81b | ||
|
|
22bb112ead | ||
|
|
af14981d83 | ||
|
|
9f3c111766 | ||
|
|
c2e4f93870 | ||
|
|
8e2d37d450 | ||
|
|
29040f3c8b | ||
|
|
6746a9a45e | ||
|
|
c768923b77 | ||
|
|
0d0099e633 | ||
|
|
bea736aeae | ||
|
|
31190ced31 | ||
|
|
575ee4de2c | ||
|
|
dfa696859a | ||
|
|
32b5b0363f | ||
|
|
c69e40942e | ||
|
|
8cb07685fd | ||
|
|
81a5a871d9 | ||
|
|
3e7b1ac938 | ||
|
|
16afe3ecbf | ||
|
|
2885ddd5f7 | ||
|
|
f9ab643475 | ||
|
|
17bb7e6953 | ||
|
|
b615704d4a | ||
|
|
c47f0030ec | ||
|
|
cb0300fc7b | ||
|
|
7cbfce747a | ||
|
|
dd99c5fde9 | ||
|
|
c4a09d67eb | ||
|
|
bf13c95fb0 | ||
|
|
30d6779baa | ||
|
|
d0889ab9de | ||
|
|
478e54ad47 | ||
|
|
3b36d6c3ba | ||
|
|
b9f4ee2d4e | ||
|
|
1b419bc615 | ||
|
|
961df0a5a5 | ||
|
|
491948dbcb | ||
|
|
7a11300336 | ||
|
|
dba22db54d | ||
|
|
6cbd3bc8c2 | ||
|
|
74762b369e | ||
|
|
5d7f36e9b2 | ||
|
|
b0be9d8b60 | ||
|
|
9d9fefbb28 | ||
|
|
584d1a41c7 | ||
|
|
a938c2f5a5 | ||
|
|
9f83f0fcd7 | ||
|
|
10980ed68c | ||
|
|
da6b42b2f0 | ||
|
|
5dcc0ce632 | ||
|
|
a34543f81e | ||
|
|
869f5375eb | ||
|
|
47d719a493 | ||
|
|
8aa5ad6ded | ||
|
|
a8cf5a4fd9 | ||
|
|
5c1ad0856a | ||
|
|
d2be7b6fd6 | ||
|
|
f22f7677a6 | ||
|
|
497fcf0e48 | ||
|
|
cceb518d09 | ||
|
|
ae27549baf | ||
|
|
8ba31a8985 | ||
|
|
4735db1064 | ||
|
|
612d6b4206 | ||
|
|
d354a1dfab | ||
|
|
d52d3f3784 | ||
|
|
22c443df83 | ||
|
|
8ffa333bc9 | ||
|
|
717a3ffcb2 | ||
|
|
d4fcdda9fb | ||
|
|
7f65b685b3 | ||
|
|
acf4c9b588 | ||
|
|
10cf809e7c | ||
|
|
3b6786bd51 | ||
|
|
5cdbe4620a | ||
|
|
8253325365 | ||
|
|
d100f3c0cb | ||
|
|
c1322c7c89 | ||
|
|
d9b5b5d0de | ||
|
|
20d077e3af | ||
|
|
97bde20b84 | ||
|
|
b1100c66eb | ||
|
|
d645b98261 | ||
|
|
31b846cf99 | ||
|
|
f1f1e39f89 | ||
|
|
3e4551b082 | ||
|
|
1fe8f5195f | ||
|
|
6f43581752 | ||
|
|
ce349ac99f | ||
|
|
38d1b296df | ||
|
|
a51ef005ac | ||
|
|
611f76238d | ||
|
|
7ef0db981f |
61
changelog.md
61
changelog.md
@@ -1,3 +1,64 @@
|
||||
# 0.3.14
|
||||
|
||||
* Ethereum uses standard BIP44 as per majority of wallets (Issue 378)
|
||||
|
||||
# 0.3.13
|
||||
|
||||
* Add Thought network
|
||||
* Add Energyweb network
|
||||
* Add Elastos network
|
||||
* Add Groestlcoin
|
||||
* Fix for syscoin network
|
||||
* Add BSV, RPD, MONKEY, ARYA
|
||||
* Rename Zencash to Horizen
|
||||
* Update Hush network
|
||||
* Add CasinoCoin
|
||||
* Add CPUchain
|
||||
* Add Wagerr
|
||||
* Add VeChain
|
||||
* Option to not use 'change' field for ethereum networks in bip45
|
||||
* Add segwit parameters for MONKEY, BCA, BTC, MONA, SYS, VIA, DOGEt, LTCt
|
||||
* Convert mnemonic back to raw entropy
|
||||
* Add 2-of-3 phrase cards
|
||||
* Move position of hardened addresses checkbox to address table
|
||||
|
||||
# 0.3.12
|
||||
|
||||
* Fix typos
|
||||
* Fix DigiByte signing message
|
||||
* Add DeepOnion network
|
||||
* Add EOS network
|
||||
* Add LTC testnetwork
|
||||
* Add DOGE testnetwork
|
||||
* Add Stellar network
|
||||
* Add TWINS network
|
||||
* Add FIX network
|
||||
|
||||
# 0.3.11
|
||||
|
||||
* Add NIX network
|
||||
* Fix coin parameters for NMC, XMY, CLAM, ONX, LKR
|
||||
* Add DEXON network
|
||||
* Add Nebulas network
|
||||
* Add LSP network
|
||||
* Fix Crown network address format
|
||||
* Add Ellaism network
|
||||
* Add Etheresocial network
|
||||
* Add Bolivarcoin network
|
||||
* Force spellcheck and autocomplete to be off
|
||||
|
||||
# 0.3.10
|
||||
|
||||
* Add Phore network
|
||||
* Add Blocknode network
|
||||
* Add Ravencoin network
|
||||
* Add Safecoin network
|
||||
* Add LitecoinZ network
|
||||
* Add LKRcoin network
|
||||
* Update Peercoin scripthash parameter
|
||||
* Add Blockstamp network
|
||||
* Remove old info regarding use of private keys
|
||||
|
||||
# 0.3.9
|
||||
|
||||
* Update BTG signing message
|
||||
|
||||
22
libs/base-x/LICENSE.md
Normal file
22
libs/base-x/LICENSE.md
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 base-x contributors
|
||||
Copyright (c) 2014-2018 The Bitcoin Core developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
44
libs/base-x/package.json
Normal file
44
libs/base-x/package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "base-x",
|
||||
"version": "3.0.7",
|
||||
"description": "Fast base encoding / decoding of any given alphabet",
|
||||
"keywords": [
|
||||
"base-x",
|
||||
"base58",
|
||||
"base62",
|
||||
"base64",
|
||||
"crypto",
|
||||
"crytography",
|
||||
"decode",
|
||||
"decoding",
|
||||
"encode",
|
||||
"encoding"
|
||||
],
|
||||
"homepage": "https://github.com/cryptocoinjs/base-x",
|
||||
"bugs": {
|
||||
"url": "https://github.com/cryptocoinjs/base-x/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Daniel Cousens",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"main": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cryptocoinjs/base-x.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p ./tsconfig.json ; standard --fix; browserify src/index.js --standalone basex > /tmp/base-x.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "12.0.10",
|
||||
"standard": "^10.0.3",
|
||||
"tape": "^4.5.1",
|
||||
"typescript": "3.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
}
|
||||
4
libs/base-x/readme.md
Normal file
4
libs/base-x/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/base-x.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
161
libs/base-x/ts_src/index.ts
Normal file
161
libs/base-x/ts_src/index.ts
Normal file
@@ -0,0 +1,161 @@
|
||||
// base-x encoding / decoding
|
||||
// Copyright (c) 2018 base-x contributors
|
||||
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
// @ts-ignore
|
||||
const _Buffer = require('safe-buffer').Buffer;
|
||||
|
||||
function base (ALPHABET: string): base.BaseConverter {
|
||||
if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long')
|
||||
|
||||
const BASE_MAP = new Uint8Array(256)
|
||||
BASE_MAP.fill(255)
|
||||
|
||||
for (let i = 0; i < ALPHABET.length; i++) {
|
||||
const x = ALPHABET.charAt(i)
|
||||
const xc = x.charCodeAt(0)
|
||||
|
||||
if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous')
|
||||
BASE_MAP[xc] = i
|
||||
}
|
||||
|
||||
const BASE = ALPHABET.length
|
||||
const LEADER = ALPHABET.charAt(0)
|
||||
const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up
|
||||
const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up
|
||||
|
||||
function encode (source: Buffer): string {
|
||||
if (!_Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
|
||||
if (source.length === 0) return ''
|
||||
|
||||
// Skip & count leading zeroes.
|
||||
let zeroes = 0
|
||||
let length = 0
|
||||
let pbegin = 0
|
||||
const pend = source.length
|
||||
|
||||
while (pbegin !== pend && source[pbegin] === 0) {
|
||||
pbegin++
|
||||
zeroes++
|
||||
}
|
||||
|
||||
// Allocate enough space in big-endian base58 representation.
|
||||
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0
|
||||
const b58 = new Uint8Array(size)
|
||||
|
||||
// Process the bytes.
|
||||
while (pbegin !== pend) {
|
||||
let carry = source[pbegin]
|
||||
|
||||
// Apply "b58 = b58 * 256 + ch".
|
||||
let i = 0
|
||||
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
||||
carry += (256 * b58[it1]) >>> 0
|
||||
b58[it1] = (carry % BASE) >>> 0
|
||||
carry = (carry / BASE) >>> 0
|
||||
}
|
||||
|
||||
if (carry !== 0) throw new Error('Non-zero carry')
|
||||
length = i
|
||||
pbegin++
|
||||
}
|
||||
|
||||
// Skip leading zeroes in base58 result.
|
||||
let it2 = size - length
|
||||
while (it2 !== size && b58[it2] === 0) {
|
||||
it2++
|
||||
}
|
||||
|
||||
// Translate the result into a string.
|
||||
let str = LEADER.repeat(zeroes)
|
||||
for (; it2 < size; ++it2) str += ALPHABET.charAt(b58[it2])
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
function decodeUnsafe (source: string): Buffer | undefined {
|
||||
if (typeof source !== 'string') throw new TypeError('Expected String')
|
||||
if (source.length === 0) return _Buffer.alloc(0)
|
||||
|
||||
let psz = 0
|
||||
|
||||
// Skip leading spaces.
|
||||
if (source[psz] === ' ') return
|
||||
|
||||
// Skip and count leading '1's.
|
||||
let zeroes = 0
|
||||
let length = 0
|
||||
while (source[psz] === LEADER) {
|
||||
zeroes++
|
||||
psz++
|
||||
}
|
||||
|
||||
// Allocate enough space in big-endian base256 representation.
|
||||
const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.
|
||||
const b256 = new Uint8Array(size)
|
||||
|
||||
// Process the characters.
|
||||
while (source[psz]) {
|
||||
// Decode character
|
||||
let carry = BASE_MAP[source.charCodeAt(psz)]
|
||||
|
||||
// Invalid character
|
||||
if (carry === 255) return
|
||||
|
||||
let i = 0
|
||||
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
||||
carry += (BASE * b256[it3]) >>> 0
|
||||
b256[it3] = (carry % 256) >>> 0
|
||||
carry = (carry / 256) >>> 0
|
||||
}
|
||||
|
||||
if (carry !== 0) throw new Error('Non-zero carry')
|
||||
length = i
|
||||
psz++
|
||||
}
|
||||
|
||||
// Skip trailing spaces.
|
||||
if (source[psz] === ' ') return
|
||||
|
||||
// Skip leading zeroes in b256.
|
||||
let it4 = size - length
|
||||
while (it4 !== size && b256[it4] === 0) {
|
||||
it4++
|
||||
}
|
||||
|
||||
const vch = _Buffer.allocUnsafe(zeroes + (size - it4))
|
||||
vch.fill(0x00, 0, zeroes)
|
||||
|
||||
let j = zeroes
|
||||
while (it4 !== size) {
|
||||
vch[j++] = b256[it4++]
|
||||
}
|
||||
|
||||
return vch
|
||||
}
|
||||
|
||||
function decode (string: string): Buffer {
|
||||
const buffer = decodeUnsafe(string)
|
||||
if (buffer) return buffer
|
||||
|
||||
throw new Error('Non-base' + BASE + ' character')
|
||||
}
|
||||
|
||||
return {
|
||||
encode: encode,
|
||||
decodeUnsafe: decodeUnsafe,
|
||||
decode: decode
|
||||
}
|
||||
}
|
||||
|
||||
export = base;
|
||||
|
||||
declare namespace base {
|
||||
interface BaseConverter {
|
||||
encode(buffer: Buffer): string;
|
||||
decodeUnsafe(string: string): Buffer | undefined;
|
||||
decode(string: string): Buffer;
|
||||
}
|
||||
}
|
||||
31
libs/base-x/tsconfig.json
Normal file
31
libs/base-x/tsconfig.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "commonjs",
|
||||
"outDir": "./src",
|
||||
"declaration": true,
|
||||
"rootDir": "./ts_src",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"allowJs": false,
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictBindCallApply": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"esModuleInterop": false,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": [
|
||||
"ts_src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*.spec.ts",
|
||||
"node_modules/**/*"
|
||||
]
|
||||
}
|
||||
244
libs/bitcoinjs-bip38/index.js
Normal file
244
libs/bitcoinjs-bip38/index.js
Normal file
@@ -0,0 +1,244 @@
|
||||
var aes = require('browserify-aes')
|
||||
var assert = require('assert')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var bs58check = require('bs58check')
|
||||
var createHash = require('create-hash')
|
||||
var scrypt = require('scryptsy')
|
||||
var xor = require('buffer-xor/inplace')
|
||||
|
||||
var ecurve = require('ecurve')
|
||||
var curve = ecurve.getCurveByName('secp256k1')
|
||||
|
||||
var BigInteger = require('bigi')
|
||||
|
||||
// constants
|
||||
var SCRYPT_PARAMS = {
|
||||
N: 16384, // specified by BIP38
|
||||
r: 8,
|
||||
p: 8
|
||||
}
|
||||
var NULL = Buffer.alloc(0)
|
||||
|
||||
function hash160 (buffer) {
|
||||
var hash
|
||||
try {
|
||||
hash = createHash('rmd160')
|
||||
} catch (e) {
|
||||
hash = createHash('ripemd160')
|
||||
}
|
||||
return hash.update(
|
||||
createHash('sha256').update(buffer).digest()
|
||||
).digest()
|
||||
}
|
||||
|
||||
function hash256 (buffer) {
|
||||
return createHash('sha256').update(
|
||||
createHash('sha256').update(buffer).digest()
|
||||
).digest()
|
||||
}
|
||||
|
||||
function getAddress (d, compressed) {
|
||||
var Q = curve.G.multiply(d).getEncoded(compressed)
|
||||
var hash = hash160(Q)
|
||||
var payload = Buffer.allocUnsafe(21)
|
||||
payload.writeUInt8(0x00, 0) // XXX TODO FIXME bitcoin only??? damn you BIP38
|
||||
hash.copy(payload, 1)
|
||||
|
||||
return bs58check.encode(payload)
|
||||
}
|
||||
|
||||
function encryptRaw (buffer, compressed, passphrase, progressCallback, scryptParams) {
|
||||
if (buffer.length !== 32) throw new Error('Invalid private key length')
|
||||
scryptParams = scryptParams || SCRYPT_PARAMS
|
||||
|
||||
var d = BigInteger.fromBuffer(buffer)
|
||||
var address = getAddress(d, compressed)
|
||||
var secret = Buffer.from(passphrase, 'utf8')
|
||||
var salt = hash256(address).slice(0, 4)
|
||||
|
||||
var N = scryptParams.N
|
||||
var r = scryptParams.r
|
||||
var p = scryptParams.p
|
||||
|
||||
var scryptBuf = scrypt(secret, salt, N, r, p, 64, progressCallback)
|
||||
var derivedHalf1 = scryptBuf.slice(0, 32)
|
||||
var derivedHalf2 = scryptBuf.slice(32, 64)
|
||||
|
||||
var xorBuf = xor(derivedHalf1, buffer)
|
||||
var cipher = aes.createCipheriv('aes-256-ecb', derivedHalf2, NULL)
|
||||
cipher.setAutoPadding(false)
|
||||
cipher.end(xorBuf)
|
||||
|
||||
var cipherText = cipher.read()
|
||||
|
||||
// 0x01 | 0x42 | flagByte | salt (4) | cipherText (32)
|
||||
var result = Buffer.allocUnsafe(7 + 32)
|
||||
result.writeUInt8(0x01, 0)
|
||||
result.writeUInt8(0x42, 1)
|
||||
result.writeUInt8(compressed ? 0xe0 : 0xc0, 2)
|
||||
salt.copy(result, 3)
|
||||
cipherText.copy(result, 7)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function encrypt (buffer, compressed, passphrase, progressCallback, scryptParams) {
|
||||
return bs58check.encode(encryptRaw(buffer, compressed, passphrase, progressCallback, scryptParams))
|
||||
}
|
||||
|
||||
// some of the techniques borrowed from: https://github.com/pointbiz/bitaddress.org
|
||||
function decryptRaw (buffer, passphrase, progressCallback, scryptParams) {
|
||||
// 39 bytes: 2 bytes prefix, 37 bytes payload
|
||||
if (buffer.length !== 39) throw new Error('Invalid BIP38 data length')
|
||||
if (buffer.readUInt8(0) !== 0x01) throw new Error('Invalid BIP38 prefix')
|
||||
scryptParams = scryptParams || SCRYPT_PARAMS
|
||||
|
||||
// check if BIP38 EC multiply
|
||||
var type = buffer.readUInt8(1)
|
||||
if (type === 0x43) return decryptECMult(buffer, passphrase, progressCallback, scryptParams)
|
||||
if (type !== 0x42) throw new Error('Invalid BIP38 type')
|
||||
|
||||
passphrase = Buffer.from(passphrase, 'utf8')
|
||||
|
||||
var flagByte = buffer.readUInt8(2)
|
||||
var compressed = flagByte === 0xe0
|
||||
if (!compressed && flagByte !== 0xc0) throw new Error('Invalid BIP38 compression flag')
|
||||
|
||||
var N = scryptParams.N
|
||||
var r = scryptParams.r
|
||||
var p = scryptParams.p
|
||||
|
||||
var salt = buffer.slice(3, 7)
|
||||
var scryptBuf = scrypt(passphrase, salt, N, r, p, 64, progressCallback)
|
||||
var derivedHalf1 = scryptBuf.slice(0, 32)
|
||||
var derivedHalf2 = scryptBuf.slice(32, 64)
|
||||
|
||||
var privKeyBuf = buffer.slice(7, 7 + 32)
|
||||
var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, NULL)
|
||||
decipher.setAutoPadding(false)
|
||||
decipher.end(privKeyBuf)
|
||||
|
||||
var plainText = decipher.read()
|
||||
var privateKey = xor(derivedHalf1, plainText)
|
||||
|
||||
// verify salt matches address
|
||||
var d = BigInteger.fromBuffer(privateKey)
|
||||
var address = getAddress(d, compressed)
|
||||
var checksum = hash256(address).slice(0, 4)
|
||||
assert.deepStrictEqual(salt, checksum)
|
||||
|
||||
return {
|
||||
privateKey: privateKey,
|
||||
compressed: compressed
|
||||
}
|
||||
}
|
||||
|
||||
function decrypt (string, passphrase, progressCallback, scryptParams) {
|
||||
return decryptRaw(bs58check.decode(string), passphrase, progressCallback, scryptParams)
|
||||
}
|
||||
|
||||
function decryptECMult (buffer, passphrase, progressCallback, scryptParams) {
|
||||
passphrase = Buffer.from(passphrase, 'utf8')
|
||||
buffer = buffer.slice(1) // FIXME: we can avoid this
|
||||
scryptParams = scryptParams || SCRYPT_PARAMS
|
||||
|
||||
var flag = buffer.readUInt8(1)
|
||||
var compressed = (flag & 0x20) !== 0
|
||||
var hasLotSeq = (flag & 0x04) !== 0
|
||||
|
||||
assert.strictEqual((flag & 0x24), flag, 'Invalid private key.')
|
||||
|
||||
var addressHash = buffer.slice(2, 6)
|
||||
var ownerEntropy = buffer.slice(6, 14)
|
||||
var ownerSalt
|
||||
|
||||
// 4 bytes ownerSalt if 4 bytes lot/sequence
|
||||
if (hasLotSeq) {
|
||||
ownerSalt = ownerEntropy.slice(0, 4)
|
||||
|
||||
// else, 8 bytes ownerSalt
|
||||
} else {
|
||||
ownerSalt = ownerEntropy
|
||||
}
|
||||
|
||||
var encryptedPart1 = buffer.slice(14, 22) // First 8 bytes
|
||||
var encryptedPart2 = buffer.slice(22, 38) // 16 bytes
|
||||
|
||||
var N = scryptParams.N
|
||||
var r = scryptParams.r
|
||||
var p = scryptParams.p
|
||||
var preFactor = scrypt(passphrase, ownerSalt, N, r, p, 32, progressCallback)
|
||||
|
||||
var passFactor
|
||||
if (hasLotSeq) {
|
||||
var hashTarget = Buffer.concat([preFactor, ownerEntropy])
|
||||
passFactor = hash256(hashTarget)
|
||||
} else {
|
||||
passFactor = preFactor
|
||||
}
|
||||
|
||||
var passInt = BigInteger.fromBuffer(passFactor)
|
||||
var passPoint = curve.G.multiply(passInt).getEncoded(true)
|
||||
|
||||
var seedBPass = scrypt(passPoint, Buffer.concat([addressHash, ownerEntropy]), 1024, 1, 1, 64)
|
||||
var derivedHalf1 = seedBPass.slice(0, 32)
|
||||
var derivedHalf2 = seedBPass.slice(32, 64)
|
||||
|
||||
var decipher = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
|
||||
decipher.setAutoPadding(false)
|
||||
decipher.end(encryptedPart2)
|
||||
|
||||
var decryptedPart2 = decipher.read()
|
||||
var tmp = xor(decryptedPart2, derivedHalf1.slice(16, 32))
|
||||
var seedBPart2 = tmp.slice(8, 16)
|
||||
|
||||
var decipher2 = aes.createDecipheriv('aes-256-ecb', derivedHalf2, Buffer.alloc(0))
|
||||
decipher2.setAutoPadding(false)
|
||||
decipher2.write(encryptedPart1) // first 8 bytes
|
||||
decipher2.end(tmp.slice(0, 8)) // last 8 bytes
|
||||
|
||||
var seedBPart1 = xor(decipher2.read(), derivedHalf1.slice(0, 16))
|
||||
var seedB = Buffer.concat([seedBPart1, seedBPart2], 24)
|
||||
var factorB = BigInteger.fromBuffer(hash256(seedB))
|
||||
|
||||
// d = passFactor * factorB (mod n)
|
||||
var d = passInt.multiply(factorB).mod(curve.n)
|
||||
|
||||
return {
|
||||
privateKey: d.toBuffer(32),
|
||||
compressed: compressed
|
||||
}
|
||||
}
|
||||
|
||||
function verify (string) {
|
||||
var decoded = bs58check.decodeUnsafe(string)
|
||||
if (!decoded) return false
|
||||
|
||||
if (decoded.length !== 39) return false
|
||||
if (decoded.readUInt8(0) !== 0x01) return false
|
||||
|
||||
var type = decoded.readUInt8(1)
|
||||
var flag = decoded.readUInt8(2)
|
||||
|
||||
// encrypted WIF
|
||||
if (type === 0x42) {
|
||||
if (flag !== 0xc0 && flag !== 0xe0) return false
|
||||
|
||||
// EC mult
|
||||
} else if (type === 0x43) {
|
||||
if ((flag & ~0x24)) return false
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
decrypt: decrypt,
|
||||
decryptECMult: decryptECMult,
|
||||
decryptRaw: decryptRaw,
|
||||
encrypt: encrypt,
|
||||
encryptRaw: encryptRaw,
|
||||
verify: verify
|
||||
}
|
||||
38
libs/bitcoinjs-bip38/package.json
Normal file
38
libs/bitcoinjs-bip38/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "bip38",
|
||||
"version": "2.0.2",
|
||||
"description": "BIP38 is a standard process to encrypt Bitcoin and crypto currency private keys that is impervious to brute force attacks thus protecting the user.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"bitcoin",
|
||||
"crypto",
|
||||
"cryptography",
|
||||
"litecoin"
|
||||
],
|
||||
"homepage": "http://cryptocoinjs.com/modules/currency/bip38/",
|
||||
"author": "JP Richardson",
|
||||
"dependencies": {
|
||||
"bigi": "^1.2.0",
|
||||
"browserify-aes": "^1.0.1",
|
||||
"bs58check": "<3.0.0",
|
||||
"buffer-xor": "^1.0.2",
|
||||
"create-hash": "^1.1.1",
|
||||
"ecurve": "^1.0.0",
|
||||
"scryptsy": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"repository": {
|
||||
"url": "git@github.com:bitcoinjs/bip38.git",
|
||||
"type": "git"
|
||||
},
|
||||
"scripts": {
|
||||
"browser-test": "mochify --wd -R spec --timeout 100000",
|
||||
"build": "browserify index.js --standalone bitcoinjs-bip38 > /tmp/bitcoinjs-bip38.js",
|
||||
"coverage": "istanbul cover _mocha -- --reporter list test/*.js",
|
||||
"coveralls": "npm run-script coverage && coveralls < coverage/lcov.info",
|
||||
"standard": "standard",
|
||||
"test": "npm run standard && npm run unit",
|
||||
"unit": "mocha --ui bdd --timeout 240000"
|
||||
}
|
||||
}
|
||||
4
libs/bitcoinjs-bip38/readme.md
Normal file
4
libs/bitcoinjs-bip38/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/bitcoinjs-bip38.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
5
libs/bitcoinjs-lib/bitcoinjs-lib.js
Normal file
5
libs/bitcoinjs-lib/bitcoinjs-lib.js
Normal file
@@ -0,0 +1,5 @@
|
||||
let bitcoin = require('bitcoinjs-lib')
|
||||
|
||||
module.exports = {
|
||||
bitcoin
|
||||
}
|
||||
14
libs/bitcoinjs-lib/package.json
Normal file
14
libs/bitcoinjs-lib/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "bitcoinjs-lib",
|
||||
"version": "3.3.2",
|
||||
"scripts": {
|
||||
"build": "browserify bitcoinjs-lib.js --standalone bitcoinjs > /tmp/bitcoinjs-lib.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"bitcoinjs-lib": "3.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
}
|
||||
}
|
||||
5
libs/bitcoinjs-lib/readme.md
Normal file
5
libs/bitcoinjs-lib/readme.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Build (will create a bundle and copy it to /tmp/bitcoinjs-lib.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
manually add changes in https://github.com/iancoleman/bip39/commit/0702ecd3520c44cb8016f80329dcb5a3c8df88fc
|
||||
736
libs/ethereumjs-util/index.js
Normal file
736
libs/ethereumjs-util/index.js
Normal file
@@ -0,0 +1,736 @@
|
||||
const createKeccakHash = require('keccak')
|
||||
const secp256k1 = require('secp256k1')
|
||||
const assert = require('assert')
|
||||
const rlp = require('rlp')
|
||||
const BN = require('bn.js')
|
||||
const createHash = require('create-hash')
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
Object.assign(exports, require('ethjs-util'))
|
||||
|
||||
/**
|
||||
* the max integer that this VM can handle (a ```BN```)
|
||||
* @var {BN} MAX_INTEGER
|
||||
*/
|
||||
exports.MAX_INTEGER = new BN('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)
|
||||
|
||||
/**
|
||||
* 2^256 (a ```BN```)
|
||||
* @var {BN} TWO_POW256
|
||||
*/
|
||||
exports.TWO_POW256 = new BN('10000000000000000000000000000000000000000000000000000000000000000', 16)
|
||||
|
||||
/**
|
||||
* Keccak-256 hash of null (a ```String```)
|
||||
* @var {String} KECCAK256_NULL_S
|
||||
*/
|
||||
exports.KECCAK256_NULL_S = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
|
||||
|
||||
/**
|
||||
* Keccak-256 hash of null (a ```Buffer```)
|
||||
* @var {Buffer} KECCAK256_NULL
|
||||
*/
|
||||
exports.KECCAK256_NULL = Buffer.from(exports.KECCAK256_NULL_S, 'hex')
|
||||
|
||||
/**
|
||||
* Keccak-256 of an RLP of an empty array (a ```String```)
|
||||
* @var {String} KECCAK256_RLP_ARRAY_S
|
||||
*/
|
||||
exports.KECCAK256_RLP_ARRAY_S = '1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
|
||||
|
||||
/**
|
||||
* Keccak-256 of an RLP of an empty array (a ```Buffer```)
|
||||
* @var {Buffer} KECCAK256_RLP_ARRAY
|
||||
*/
|
||||
exports.KECCAK256_RLP_ARRAY = Buffer.from(exports.KECCAK256_RLP_ARRAY_S, 'hex')
|
||||
|
||||
/**
|
||||
* Keccak-256 hash of the RLP of null (a ```String```)
|
||||
* @var {String} KECCAK256_RLP_S
|
||||
*/
|
||||
exports.KECCAK256_RLP_S = '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
|
||||
|
||||
/**
|
||||
* Keccak-256 hash of the RLP of null (a ```Buffer```)
|
||||
* @var {Buffer} KECCAK256_RLP
|
||||
*/
|
||||
exports.KECCAK256_RLP = Buffer.from(exports.KECCAK256_RLP_S, 'hex')
|
||||
|
||||
/**
|
||||
* [`BN`](https://github.com/indutny/bn.js)
|
||||
* @var {Function}
|
||||
*/
|
||||
exports.BN = BN
|
||||
|
||||
/**
|
||||
* [`rlp`](https://github.com/ethereumjs/rlp)
|
||||
* @var {Function}
|
||||
*/
|
||||
exports.rlp = rlp
|
||||
|
||||
/**
|
||||
* [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)
|
||||
* @var {Object}
|
||||
*/
|
||||
exports.secp256k1 = secp256k1
|
||||
|
||||
/**
|
||||
* Returns a buffer filled with 0s
|
||||
* @method zeros
|
||||
* @param {Number} bytes the number of bytes the buffer should be
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.zeros = function (bytes) {
|
||||
return Buffer.allocUnsafe(bytes).fill(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a zero address
|
||||
* @method zeroAddress
|
||||
* @return {String}
|
||||
*/
|
||||
exports.zeroAddress = function () {
|
||||
const addressLength = 20
|
||||
const zeroAddress = exports.zeros(addressLength)
|
||||
return exports.bufferToHex(zeroAddress)
|
||||
}
|
||||
|
||||
/**
|
||||
* Left Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
|
||||
* Or it truncates the beginning if it exceeds.
|
||||
* @method lsetLength
|
||||
* @param {Buffer|Array} msg the value to pad
|
||||
* @param {Number} length the number of bytes the output should be
|
||||
* @param {Boolean} [right=false] whether to start padding form the left or right
|
||||
* @return {Buffer|Array}
|
||||
*/
|
||||
exports.setLengthLeft = exports.setLength = function (msg, length, right) {
|
||||
const buf = exports.zeros(length)
|
||||
msg = exports.toBuffer(msg)
|
||||
if (right) {
|
||||
if (msg.length < length) {
|
||||
msg.copy(buf)
|
||||
return buf
|
||||
}
|
||||
return msg.slice(0, length)
|
||||
} else {
|
||||
if (msg.length < length) {
|
||||
msg.copy(buf, length - msg.length)
|
||||
return buf
|
||||
}
|
||||
return msg.slice(-length)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Right Pads an `Array` or `Buffer` with leading zeros till it has `length` bytes.
|
||||
* Or it truncates the beginning if it exceeds.
|
||||
* @param {Buffer|Array} msg the value to pad
|
||||
* @param {Number} length the number of bytes the output should be
|
||||
* @return {Buffer|Array}
|
||||
*/
|
||||
exports.setLengthRight = function (msg, length) {
|
||||
return exports.setLength(msg, length, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims leading zeros from a `Buffer` or an `Array`
|
||||
* @param {Buffer|Array|String} a
|
||||
* @return {Buffer|Array|String}
|
||||
*/
|
||||
exports.unpad = exports.stripZeros = function (a) {
|
||||
a = exports.stripHexPrefix(a)
|
||||
let first = a[0]
|
||||
while (a.length > 0 && first.toString() === '0') {
|
||||
a = a.slice(1)
|
||||
first = a[0]
|
||||
}
|
||||
return a
|
||||
}
|
||||
/**
|
||||
* Attempts to turn a value into a `Buffer`. As input it supports `Buffer`, `String`, `Number`, null/undefined, `BN` and other objects with a `toArray()` method.
|
||||
* @param {*} v the value
|
||||
*/
|
||||
exports.toBuffer = function (v) {
|
||||
if (!Buffer.isBuffer(v)) {
|
||||
if (Array.isArray(v)) {
|
||||
v = Buffer.from(v)
|
||||
} else if (typeof v === 'string') {
|
||||
if (exports.isHexString(v)) {
|
||||
v = Buffer.from(exports.padToEven(exports.stripHexPrefix(v)), 'hex')
|
||||
} else {
|
||||
v = Buffer.from(v)
|
||||
}
|
||||
} else if (typeof v === 'number') {
|
||||
v = exports.intToBuffer(v)
|
||||
} else if (v === null || v === undefined) {
|
||||
v = Buffer.allocUnsafe(0)
|
||||
} else if (BN.isBN(v)) {
|
||||
v = v.toArrayLike(Buffer)
|
||||
} else if (v.toArray) {
|
||||
// converts a BN to a Buffer
|
||||
v = Buffer.from(v.toArray())
|
||||
} else {
|
||||
throw new Error('invalid type')
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `Buffer` to a `Number`
|
||||
* @param {Buffer} buf
|
||||
* @return {Number}
|
||||
* @throws If the input number exceeds 53 bits.
|
||||
*/
|
||||
exports.bufferToInt = function (buf) {
|
||||
return new BN(exports.toBuffer(buf)).toNumber()
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `Buffer` into a hex `String`
|
||||
* @param {Buffer} buf
|
||||
* @return {String}
|
||||
*/
|
||||
exports.bufferToHex = function (buf) {
|
||||
buf = exports.toBuffer(buf)
|
||||
return '0x' + buf.toString('hex')
|
||||
}
|
||||
|
||||
/**
|
||||
* Interprets a `Buffer` as a signed integer and returns a `BN`. Assumes 256-bit numbers.
|
||||
* @param {Buffer} num
|
||||
* @return {BN}
|
||||
*/
|
||||
exports.fromSigned = function (num) {
|
||||
return new BN(num).fromTwos(256)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `BN` to an unsigned integer and returns it as a `Buffer`. Assumes 256-bit numbers.
|
||||
* @param {BN} num
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.toUnsigned = function (num) {
|
||||
return Buffer.from(num.toTwos(256).toArray())
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Keccak hash of the input
|
||||
* @param {Buffer|Array|String|Number} a the input data
|
||||
* @param {Number} [bits=256] the Keccak width
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.keccak = function (a, bits) {
|
||||
a = exports.toBuffer(a)
|
||||
if (!bits) bits = 256
|
||||
|
||||
return createKeccakHash('keccak' + bits).update(a).digest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Keccak-256 hash of the input, alias for keccak(a, 256)
|
||||
* @param {Buffer|Array|String|Number} a the input data
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.keccak256 = function (a) {
|
||||
return exports.keccak(a)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates SHA256 hash of the input
|
||||
* @param {Buffer|Array|String|Number} a the input data
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.sha256 = function (a) {
|
||||
a = exports.toBuffer(a)
|
||||
return createHash('sha256').update(a).digest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates RIPEMD160 hash of the input
|
||||
* @param {Buffer|Array|String|Number} a the input data
|
||||
* @param {Boolean} padded whether it should be padded to 256 bits or not
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.ripemd160 = function (a, padded) {
|
||||
a = exports.toBuffer(a)
|
||||
const hash = createHash('rmd160').update(a).digest()
|
||||
if (padded === true) {
|
||||
return exports.setLength(hash, 32)
|
||||
} else {
|
||||
return hash
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates SHA-3 hash of the RLP encoded version of the input
|
||||
* @param {Buffer|Array|String|Number} a the input data
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.rlphash = function (a) {
|
||||
return exports.keccak(rlp.encode(a))
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the private key satisfies the rules of the curve secp256k1.
|
||||
* @param {Buffer} privateKey
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isValidPrivate = function (privateKey) {
|
||||
return secp256k1.privateKeyVerify(privateKey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the public key satisfies the rules of the curve secp256k1
|
||||
* and the requirements of Ethereum.
|
||||
* @param {Buffer} publicKey The two points of an uncompressed key, unless sanitize is enabled
|
||||
* @param {Boolean} [sanitize=false] Accept public keys in other formats
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isValidPublic = function (publicKey, sanitize) {
|
||||
if (publicKey.length === 64) {
|
||||
// Convert to SEC1 for secp256k1
|
||||
return secp256k1.publicKeyVerify(Buffer.concat([ Buffer.from([4]), publicKey ]))
|
||||
}
|
||||
|
||||
if (!sanitize) {
|
||||
return false
|
||||
}
|
||||
|
||||
return secp256k1.publicKeyVerify(publicKey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ethereum address of a given public key.
|
||||
* Accepts "Ethereum public keys" and SEC1 encoded keys.
|
||||
* @param {Buffer} pubKey The two points of an uncompressed key, unless sanitize is enabled
|
||||
* @param {Boolean} [sanitize=false] Accept public keys in other formats
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.pubToAddress = exports.publicToAddress = function (pubKey, sanitize) {
|
||||
pubKey = exports.toBuffer(pubKey)
|
||||
if (sanitize && (pubKey.length !== 64)) {
|
||||
pubKey = secp256k1.publicKeyConvert(pubKey, false).slice(1)
|
||||
}
|
||||
assert(pubKey.length === 64)
|
||||
// Only take the lower 160bits of the hash
|
||||
return exports.keccak(pubKey).slice(-20)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ethereum public key of a given private key
|
||||
* @param {Buffer} privateKey A private key must be 256 bits wide
|
||||
* @return {Buffer}
|
||||
*/
|
||||
const privateToPublic = exports.privateToPublic = function (privateKey) {
|
||||
privateKey = exports.toBuffer(privateKey)
|
||||
// skip the type flag and use the X, Y points
|
||||
return secp256k1.publicKeyCreate(privateKey, false).slice(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a public key to the Ethereum format.
|
||||
* @param {Buffer} publicKey
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.importPublic = function (publicKey) {
|
||||
publicKey = exports.toBuffer(publicKey)
|
||||
if (publicKey.length !== 64) {
|
||||
publicKey = secp256k1.publicKeyConvert(publicKey, false).slice(1)
|
||||
}
|
||||
return publicKey
|
||||
}
|
||||
|
||||
/**
|
||||
* ECDSA sign
|
||||
* @param {Buffer} msgHash
|
||||
* @param {Buffer} privateKey
|
||||
* @param {Number} [chainId]
|
||||
* @return {Object}
|
||||
*/
|
||||
exports.ecsign = function (msgHash, privateKey, chainId) {
|
||||
const sig = secp256k1.sign(msgHash, privateKey)
|
||||
|
||||
const ret = {}
|
||||
ret.r = sig.signature.slice(0, 32)
|
||||
ret.s = sig.signature.slice(32, 64)
|
||||
ret.v = chainId ? sig.recovery + (chainId * 2 + 35) : sig.recovery + 27
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call.
|
||||
* The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign`
|
||||
* call for a given `message`, or fed to `ecrecover` along with a signature to recover the public key
|
||||
* used to produce the signature.
|
||||
* @param message
|
||||
* @returns {Buffer} hash
|
||||
*/
|
||||
exports.hashPersonalMessage = function (message) {
|
||||
const prefix = exports.toBuffer('\u0019Ethereum Signed Message:\n' + message.length.toString())
|
||||
return exports.keccak(Buffer.concat([prefix, message]))
|
||||
}
|
||||
|
||||
/**
|
||||
* ECDSA public key recovery from signature
|
||||
* @param {Buffer} msgHash
|
||||
* @param {Number} v
|
||||
* @param {Buffer} r
|
||||
* @param {Buffer} s
|
||||
* @param {Number} [chainId]
|
||||
* @return {Buffer} publicKey
|
||||
*/
|
||||
exports.ecrecover = function (msgHash, v, r, s, chainId) {
|
||||
const signature = Buffer.concat([exports.setLength(r, 32), exports.setLength(s, 32)], 64)
|
||||
const recovery = calculateSigRecovery(v, chainId)
|
||||
if (!isValidSigRecovery(recovery)) {
|
||||
throw new Error('Invalid signature v value')
|
||||
}
|
||||
const senderPubKey = secp256k1.recover(msgHash, signature, recovery)
|
||||
return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert signature parameters into the format of `eth_sign` RPC method
|
||||
* @param {Number} v
|
||||
* @param {Buffer} r
|
||||
* @param {Buffer} s
|
||||
* @param {Number} [chainId]
|
||||
* @return {String} sig
|
||||
*/
|
||||
exports.toRpcSig = function (v, r, s, chainId) {
|
||||
let recovery = calculateSigRecovery(v, chainId)
|
||||
if (!isValidSigRecovery(recovery)) {
|
||||
throw new Error('Invalid signature v value')
|
||||
}
|
||||
|
||||
// geth (and the RPC eth_sign method) uses the 65 byte format used by Bitcoin
|
||||
return exports.bufferToHex(Buffer.concat([
|
||||
exports.setLengthLeft(r, 32),
|
||||
exports.setLengthLeft(s, 32),
|
||||
exports.toBuffer(v)
|
||||
]))
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert signature format of the `eth_sign` RPC method to signature parameters
|
||||
* NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
|
||||
* @param {String} sig
|
||||
* @return {Object}
|
||||
*/
|
||||
exports.fromRpcSig = function (sig) {
|
||||
sig = exports.toBuffer(sig)
|
||||
|
||||
// NOTE: with potential introduction of chainId this might need to be updated
|
||||
if (sig.length !== 65) {
|
||||
throw new Error('Invalid signature length')
|
||||
}
|
||||
|
||||
let v = sig[64]
|
||||
// support both versions of `eth_sign` responses
|
||||
if (v < 27) {
|
||||
v += 27
|
||||
}
|
||||
|
||||
return {
|
||||
v: v,
|
||||
r: sig.slice(0, 32),
|
||||
s: sig.slice(32, 64)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ethereum address of a given private key
|
||||
* @param {Buffer} privateKey A private key must be 256 bits wide
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.privateToAddress = function (privateKey) {
|
||||
return exports.publicToAddress(privateToPublic(privateKey))
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the address is a valid. Accepts checksummed addresses too
|
||||
* @param {String} address
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isValidAddress = function (address) {
|
||||
return /^0x[0-9a-fA-F]{40}$/.test(address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given address is a zero address
|
||||
* @method isZeroAddress
|
||||
* @param {String} address
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isZeroAddress = function (address) {
|
||||
const zeroAddress = exports.zeroAddress()
|
||||
return zeroAddress === exports.addHexPrefix(address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a checksummed address
|
||||
* @param {String} address
|
||||
* @return {String}
|
||||
*/
|
||||
exports.toChecksumAddress = function (address) {
|
||||
address = exports.stripHexPrefix(address).toLowerCase()
|
||||
const hash = exports.keccak(address).toString('hex')
|
||||
let ret = '0x'
|
||||
|
||||
for (let i = 0; i < address.length; i++) {
|
||||
if (parseInt(hash[i], 16) >= 8) {
|
||||
ret += address[i].toUpperCase()
|
||||
} else {
|
||||
ret += address[i]
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the address is a valid checksummed address
|
||||
* @param {Buffer} address
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isValidChecksumAddress = function (address) {
|
||||
return exports.isValidAddress(address) && (exports.toChecksumAddress(address) === address)
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an address of a newly created contract
|
||||
* @param {Buffer} from the address which is creating this new address
|
||||
* @param {Buffer} nonce the nonce of the from account
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.generateAddress = function (from, nonce) {
|
||||
from = exports.toBuffer(from)
|
||||
nonce = new BN(nonce)
|
||||
|
||||
if (nonce.isZero()) {
|
||||
// in RLP we want to encode null in the case of zero nonce
|
||||
// read the RLP documentation for an answer if you dare
|
||||
nonce = null
|
||||
} else {
|
||||
nonce = Buffer.from(nonce.toArray())
|
||||
}
|
||||
|
||||
// Only take the lower 160bits of the hash
|
||||
return exports.rlphash([from, nonce]).slice(-20)
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an address for a contract created using CREATE2
|
||||
* @param {Buffer} from the address which is creating this new address
|
||||
* @param {Buffer} salt a salt
|
||||
* @param {Buffer} initCode the init code of the contract being created
|
||||
* @return {Buffer}
|
||||
*/
|
||||
exports.generateAddress2 = function (from, salt, initCode) {
|
||||
from = exports.toBuffer(from)
|
||||
salt = exports.toBuffer(salt)
|
||||
initCode = exports.toBuffer(initCode)
|
||||
|
||||
assert(from.length === 20)
|
||||
assert(salt.length === 32)
|
||||
|
||||
let address = exports.keccak256(Buffer.concat([
|
||||
Buffer.from('ff', 'hex'),
|
||||
from,
|
||||
salt,
|
||||
exports.keccak256(initCode)
|
||||
]))
|
||||
|
||||
return address.slice(-20)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the supplied address belongs to a precompiled account (Byzantium)
|
||||
* @param {Buffer|String} address
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isPrecompiled = function (address) {
|
||||
const a = exports.unpad(address)
|
||||
return a.length === 1 && a[0] >= 1 && a[0] <= 8
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds "0x" to a given `String` if it does not already start with "0x"
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
*/
|
||||
exports.addHexPrefix = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
return str
|
||||
}
|
||||
|
||||
return exports.isHexPrefixed(str) ? str : '0x' + str
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ECDSA signature
|
||||
* @method isValidSignature
|
||||
* @param {Buffer} v
|
||||
* @param {Buffer} r
|
||||
* @param {Buffer} s
|
||||
* @param {Boolean} [homestead=true]
|
||||
* @param {Number} [chainId]
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
exports.isValidSignature = function (v, r, s, homestead, chainId) {
|
||||
const SECP256K1_N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0', 16)
|
||||
const SECP256K1_N = new BN('fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141', 16)
|
||||
|
||||
if (r.length !== 32 || s.length !== 32) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!isValidSigRecovery(calculateSigRecovery(v, chainId))) {
|
||||
return false
|
||||
}
|
||||
|
||||
r = new BN(r)
|
||||
s = new BN(s)
|
||||
|
||||
if (r.isZero() || r.gt(SECP256K1_N) || s.isZero() || s.gt(SECP256K1_N)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if ((homestead === false) && (new BN(s).cmp(SECP256K1_N_DIV_2) === 1)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a `Buffer` or `Array` to JSON
|
||||
* @param {Buffer|Array} ba
|
||||
* @return {Array|String|null}
|
||||
*/
|
||||
exports.baToJSON = function (ba) {
|
||||
if (Buffer.isBuffer(ba)) {
|
||||
return '0x' + ba.toString('hex')
|
||||
} else if (ba instanceof Array) {
|
||||
const array = []
|
||||
for (let i = 0; i < ba.length; i++) {
|
||||
array.push(exports.baToJSON(ba[i]))
|
||||
}
|
||||
return array
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines properties on a `Object`. It make the assumption that underlying data is binary.
|
||||
* @param {Object} self the `Object` to define properties on
|
||||
* @param {Array} fields an array fields to define. Fields can contain:
|
||||
* * `name` - the name of the properties
|
||||
* * `length` - the number of bytes the field can have
|
||||
* * `allowLess` - if the field can be less than the length
|
||||
* * `allowEmpty`
|
||||
* @param {*} data data to be validated against the definitions
|
||||
*/
|
||||
exports.defineProperties = function (self, fields, data) {
|
||||
self.raw = []
|
||||
self._fields = []
|
||||
|
||||
// attach the `toJSON`
|
||||
self.toJSON = function (label) {
|
||||
if (label) {
|
||||
const obj = {}
|
||||
self._fields.forEach((field) => {
|
||||
obj[field] = '0x' + self[field].toString('hex')
|
||||
})
|
||||
return obj
|
||||
}
|
||||
return exports.baToJSON(this.raw)
|
||||
}
|
||||
|
||||
self.serialize = function serialize () {
|
||||
return rlp.encode(self.raw)
|
||||
}
|
||||
|
||||
fields.forEach((field, i) => {
|
||||
self._fields.push(field.name)
|
||||
function getter () {
|
||||
return self.raw[i]
|
||||
}
|
||||
function setter (v) {
|
||||
v = exports.toBuffer(v)
|
||||
|
||||
if (v.toString('hex') === '00' && !field.allowZero) {
|
||||
v = Buffer.allocUnsafe(0)
|
||||
}
|
||||
|
||||
if (field.allowLess && field.length) {
|
||||
v = exports.stripZeros(v)
|
||||
assert(field.length >= v.length, 'The field ' + field.name + ' must not have more ' + field.length + ' bytes')
|
||||
} else if (!(field.allowZero && v.length === 0) && field.length) {
|
||||
assert(field.length === v.length, 'The field ' + field.name + ' must have byte length of ' + field.length)
|
||||
}
|
||||
|
||||
self.raw[i] = v
|
||||
}
|
||||
|
||||
Object.defineProperty(self, field.name, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: getter,
|
||||
set: setter
|
||||
})
|
||||
|
||||
if (field.default) {
|
||||
self[field.name] = field.default
|
||||
}
|
||||
|
||||
// attach alias
|
||||
if (field.alias) {
|
||||
Object.defineProperty(self, field.alias, {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
set: setter,
|
||||
get: getter
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// if the constuctor is passed data
|
||||
if (data) {
|
||||
if (typeof data === 'string') {
|
||||
data = Buffer.from(exports.stripHexPrefix(data), 'hex')
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(data)) {
|
||||
data = rlp.decode(data)
|
||||
}
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
if (data.length > self._fields.length) {
|
||||
throw (new Error('wrong number of fields in data'))
|
||||
}
|
||||
|
||||
// make sure all the items are buffers
|
||||
data.forEach((d, i) => {
|
||||
self[self._fields[i]] = exports.toBuffer(d)
|
||||
})
|
||||
} else if (typeof data === 'object') {
|
||||
const keys = Object.keys(data)
|
||||
fields.forEach((field) => {
|
||||
if (keys.indexOf(field.name) !== -1) self[field.name] = data[field.name]
|
||||
if (keys.indexOf(field.alias) !== -1) self[field.alias] = data[field.alias]
|
||||
})
|
||||
} else {
|
||||
throw new Error('invalid data')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function calculateSigRecovery (v, chainId) {
|
||||
return chainId ? v - (2 * chainId + 35) : v - 27
|
||||
}
|
||||
|
||||
function isValidSigRecovery (recovery) {
|
||||
return recovery === 0 || recovery === 1
|
||||
}
|
||||
125
libs/ethereumjs-util/package.json
Normal file
125
libs/ethereumjs-util/package.json
Normal file
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"name": "ethereumjs-util",
|
||||
"version": "6.0.0",
|
||||
"description": "a collection of utility functions for Ethereum",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "browserify index.js -s ethUtil -o /tmp/ethereumjs-util.js",
|
||||
"coverage": "npm run build:dist && istanbul cover _mocha",
|
||||
"coveralls": "npm run coverage && coveralls <coverage/lcov.info",
|
||||
"lint": "standard",
|
||||
"prepublishOnly": "npm run test && npm run build:dist",
|
||||
"test": "npm run lint && npm run test:node && npm run test:browser",
|
||||
"test:browser": "npm run build:dist && karma start karma.conf.js",
|
||||
"test:node": "npm run build:dist && istanbul test mocha -- --reporter spec",
|
||||
"build:dist": "babel index.js --source-root ./ -d ./dist",
|
||||
"build:docs": "documentation build ./index.js --github --sort-order='alpha' -f md > ./docs/index.md"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ethereumjs/ethereumjs-util.git"
|
||||
},
|
||||
"keywords": [
|
||||
"ethereum",
|
||||
"utilties"
|
||||
],
|
||||
"author": "mjbecze <mjbecze@gmail.com>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Tim Coulter",
|
||||
"email": "tim@timothyjcoulter.com",
|
||||
"url": "https://github.com/tcoulter",
|
||||
"contributions": 1,
|
||||
"additions": 2,
|
||||
"deletions": 2
|
||||
},
|
||||
{
|
||||
"name": "Nick Dodson",
|
||||
"url": "https://github.com/SilentCicero",
|
||||
"contributions": 2,
|
||||
"additions": 26,
|
||||
"deletions": 2
|
||||
},
|
||||
{
|
||||
"name": "Mr. Chico",
|
||||
"url": "https://github.com/MrChico",
|
||||
"contributions": 1,
|
||||
"additions": 11,
|
||||
"deletions": 1
|
||||
},
|
||||
{
|
||||
"name": "Dũng Trần",
|
||||
"email": "tad88.dev@gmail.com",
|
||||
"url": "https://github.com/tad88dev",
|
||||
"contributions": 2,
|
||||
"additions": 5,
|
||||
"deletions": 5
|
||||
},
|
||||
{
|
||||
"name": "Alex Beregszaszi",
|
||||
"email": "alex@rtfs.hu",
|
||||
"url": "https://github.com/axic",
|
||||
"contributions": 77,
|
||||
"additions": 1796,
|
||||
"deletions": 642
|
||||
},
|
||||
{
|
||||
"name": "Taylor Gerring",
|
||||
"url": "https://github.com/tgerring",
|
||||
"contributions": 1,
|
||||
"additions": 1,
|
||||
"deletions": 1
|
||||
},
|
||||
{
|
||||
"name": "Kirill Fomichev",
|
||||
"email": "fanatid@ya.ru",
|
||||
"url": "https://github.com/fanatid",
|
||||
"contributions": 8,
|
||||
"additions": 32,
|
||||
"deletions": 16
|
||||
},
|
||||
{
|
||||
"name": "kumavis",
|
||||
"email": "aaron@kumavis.me",
|
||||
"url": "https://github.com/kumavis",
|
||||
"contributions": 2,
|
||||
"additions": 2,
|
||||
"deletions": 2
|
||||
},
|
||||
{
|
||||
"name": "Alexander Sinyagin",
|
||||
"email": "sinyagin.alexander@gmail.com",
|
||||
"url": "https://github.com/asinyagin",
|
||||
"contributions": 1,
|
||||
"additions": 3,
|
||||
"deletions": 1
|
||||
}
|
||||
],
|
||||
"license": "MPL-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ethereumjs/ethereumjs-util/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ethereumjs/ethereumjs-util",
|
||||
"dependencies": {
|
||||
"bn.js": "^4.11.0",
|
||||
"create-hash": "^1.1.2",
|
||||
"ethjs-util": "^0.1.6",
|
||||
"keccak": "^1.0.2",
|
||||
"rlp": "^2.0.0",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"secp256k1": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"standard": {
|
||||
"globals": [
|
||||
"describe",
|
||||
"it"
|
||||
],
|
||||
"ignore": [
|
||||
"dist/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
4
libs/ethereumjs-util/readme.md
Normal file
4
libs/ethereumjs-util/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/ethereumjs-util.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
1389
libs/stellar-util/package-lock.json
generated
Normal file
1389
libs/stellar-util/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
libs/stellar-util/package.json
Normal file
15
libs/stellar-util/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "stellar-util",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"build": "browserify stellar-util.js > /tmp/stellar-util.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ed25519-hd-key": "^1.0.0",
|
||||
"stellar-base": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.2.3",
|
||||
"uglify-es": "^3.3.9"
|
||||
}
|
||||
}
|
||||
4
libs/stellar-util/readme.md
Normal file
4
libs/stellar-util/readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
Build (will create a bundle and copy it to /tmp/stellar-util.js):
|
||||
|
||||
npm install
|
||||
npm run build
|
||||
16
libs/stellar-util/stellar-util.js
Normal file
16
libs/stellar-util/stellar-util.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const StellarBase = require('stellar-base');
|
||||
const edHd = require('ed25519-hd-key');
|
||||
|
||||
window.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,
|
||||
},
|
||||
}
|
||||
@@ -8,7 +8,8 @@ https://iancoleman.io/bip39/
|
||||
|
||||
## Standalone offline version
|
||||
|
||||
Download `bip39-standalone.html`
|
||||
Download `bip39-standalone.html` from
|
||||
[the releases](https://github.com/iancoleman/bip39/releases).
|
||||
|
||||
Open the file in a browser by double clicking it.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ created with the following steps:
|
||||
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`
|
||||
1. Publish to any hosted locations (eg iancoleman.github.io/bip39)
|
||||
1. Add a new post to twitter from @bip39tool with the version, link and hash
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.3.9</p>
|
||||
<p class="version">v0.3.14</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -37,7 +37,7 @@
|
||||
<div class="form-inline">
|
||||
<div class="input-group-inline">
|
||||
<span>Generate a random mnemonic</span>:
|
||||
<button class="btn generate" ><b>GENERATE</b></button>
|
||||
<button class="btn generate" ><b>GENERATE</b></button>
|
||||
<select id="strength" class="strength form-control">
|
||||
<option value="3">3</option>
|
||||
<option value="6">6</option>
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="form-group">
|
||||
<label for="entropy" class="col-sm-2 control-label">Entropy</label>
|
||||
<div class="col-sm-7">
|
||||
<textarea id="entropy" rows="2" class="entropy private-data form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards"></textarea>
|
||||
<textarea id="entropy" rows="2" class="entropy private-data form-control" placeholder="Accepts either binary, base 6, 6-sided dice, base 10, hexadecimal or cards" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
<div class="row filter-warning text-danger hidden">
|
||||
<p class="col-sm-12">
|
||||
<strong>
|
||||
@@ -169,19 +169,28 @@
|
||||
<div class="form-group">
|
||||
<label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="phrase" class="phrase private-data form-control" data-show-qr></textarea>
|
||||
<textarea id="phrase" class="phrase private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="phrase" class="col-sm-2 control-label">BIP39 Split Mnemonic</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="phraseSplit" class="phraseSplit private-data form-control" title="Only 2 of 3 cards needed to recover." rows="3"></textarea>
|
||||
<p class="help-block">
|
||||
<span id="phraseSplitWarn" class="phraseSplitWarn"></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="passphrase" class="passphrase private-data form-control"></textarea>
|
||||
<textarea id="passphrase" class="passphrase private-data form-control" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<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></textarea>
|
||||
<textarea id="seed" class="seed private-data form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -195,7 +204,7 @@
|
||||
<div class="form-group">
|
||||
<label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="root-key" class="root-key private-data form-control" data-show-qr></textarea>
|
||||
<textarea id="root-key" class="root-key private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group litecoin-ltub-container hidden">
|
||||
@@ -273,7 +282,7 @@
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<input id="change-bip44" type="text" class="change form-control" value="0">
|
||||
<input id="change-bip44" type="text" class="change form-control" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -288,7 +297,7 @@
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv-bip44" type="text" class="account-xprv private-data form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xprv-bip44" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -296,7 +305,7 @@
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub-bip44" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xpub-bip44" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -339,13 +348,6 @@
|
||||
<input id="bip32-path" type="text" class="path form-control" value="m/0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<label class="col-sm-10">
|
||||
<input class="hardened-addresses" type="checkbox">
|
||||
<span>Use hardened addresses</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="core-path" class="col-sm-2 control-label">Bitcoin Core</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -448,7 +450,7 @@
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv-bip49" type="text" class="account-xprv private-data form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xprv-bip49" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -456,7 +458,7 @@
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub-bip49" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xpub-bip49" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -575,7 +577,7 @@
|
||||
<span>Account Extended Private Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xprv-bip84" type="text" class="account-xprv private-data form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xprv-bip84" type="text" class="account-xprv private-data form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -583,7 +585,7 @@
|
||||
<span>Account Extended Public Key</span>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="account-xpub-bip84" type="text" class="account-xpub form-control" readonly data-show-qr></textarea>
|
||||
<textarea id="account-xpub-bip84" type="text" class="account-xpub form-control" readonly data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -607,13 +609,13 @@
|
||||
<div class="form-group">
|
||||
<label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Private Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="extended-priv-key" class="extended-priv-key private-data form-control" readonly="readonly" data-show-qr></textarea>
|
||||
<textarea id="extended-priv-key" class="extended-priv-key private-data form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Public Key</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr></textarea>
|
||||
<textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -653,10 +655,18 @@
|
||||
<input type="checkbox" class="use-bip38">
|
||||
<span>Encrypt private keys using BIP38 and this password:</span>
|
||||
</label>
|
||||
<input class="bip38-password private-data">
|
||||
<input class="bip38-password private-data" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
|
||||
<span>Enabling BIP38 means each key will take several minutes to generate.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input class="hardened-addresses" type="checkbox">
|
||||
<span>Use hardened addresses</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="addresses-type nav nav-tabs" role="tablist">
|
||||
<li id="table-tab" class="active">
|
||||
<a href="#table" role="tab" data-toggle="tab">Table</a>
|
||||
@@ -707,7 +717,7 @@
|
||||
</div>
|
||||
<div id="csv" class="tab-pane">
|
||||
<div class="col-md-12">
|
||||
<textarea class="csv form-control" rows="25" readonly></textarea>
|
||||
<textarea class="csv form-control" rows="25" readonly autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -748,14 +758,6 @@
|
||||
Read more at the
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki" target="_blank">official BIP49 spec</a>
|
||||
</p>
|
||||
<h3>Private Keys</h3>
|
||||
<p>
|
||||
<span>
|
||||
Use private keys at
|
||||
<a href="https://web.archive.org/web/20150707020924/https://brainwallet.org/" target="_blank">brainwallet.org</a>.
|
||||
</span>
|
||||
<span>Be careful - it can be easy to make mistakes if you don't know what you're doing.</span>
|
||||
</p>
|
||||
<h3 id="entropy-notes">Entropy</h3>
|
||||
<p>
|
||||
<span>Entropy values should not include the BIP39 checksum. This is automatically added by the tool.</span>
|
||||
@@ -931,10 +933,16 @@
|
||||
<script src="js/bitcoinjs-3.3.2.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>
|
||||
<script src="js/wordlist_japanese.js"></script>
|
||||
@@ -948,6 +956,7 @@
|
||||
<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>
|
||||
|
||||
@@ -3356,7 +3356,7 @@ var validate = validation.validate;
|
||||
|
||||
/**
|
||||
* Encodes a hash from a given type into a Bitcoin Cash address with the given prefix.
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
|
||||
* @param {string} type Type of address to generate. Either 'P2PKH' or 'P2SH'.
|
||||
@@ -3378,7 +3378,7 @@ function encode(prefix, type, hash) {
|
||||
|
||||
/**
|
||||
* Decodes the given address into its constituting prefix, type and hash. See [#encode()]{@link encode}.
|
||||
*
|
||||
*
|
||||
* @static
|
||||
* @param {string} address Address to decode. E.g.: 'bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a'.
|
||||
* @returns {object}
|
||||
@@ -3416,14 +3416,14 @@ var ValidationError = validation.ValidationError;
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
var VALID_PREFIXES = ['bitcoincash', 'bchtest', 'bchreg'];
|
||||
var VALID_PREFIXES = ['bitcoincash', 'bchtest', 'bchreg', 'simpleledger', 'slptest'];
|
||||
|
||||
/**
|
||||
* Checks whether a string is a valid prefix; ie., it has a single letter case
|
||||
* and is one of 'bitcoincash', 'bchtest', or 'bchreg'.
|
||||
* and is one of 'bitcoincash', 'bchtest', or 'bchreg', 'simpleledger' or 'slptest'.
|
||||
*
|
||||
* @private
|
||||
* @param {string} prefix
|
||||
* @param {string} prefix
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isValidPrefix(prefix) {
|
||||
@@ -3435,7 +3435,7 @@ function isValidPrefix(prefix) {
|
||||
* of the address' checksum.
|
||||
*
|
||||
* @private
|
||||
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
|
||||
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
function prefixToUint5Array(prefix) {
|
||||
@@ -3594,8 +3594,8 @@ function fromUint5Array(data) {
|
||||
* Returns the concatenation a and b.
|
||||
*
|
||||
* @private
|
||||
* @param {Uint8Array} a
|
||||
* @param {Uint8Array} b
|
||||
* @param {Uint8Array} a
|
||||
* @param {Uint8Array} b
|
||||
* @returns {Uint8Array}
|
||||
* @throws {ValidationError}
|
||||
*/
|
||||
@@ -3633,7 +3633,7 @@ function polymod(data) {
|
||||
/**
|
||||
* Verify that the payload has not been corrupted by checking that the
|
||||
* checksum is valid.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @param {string} prefix Network prefix. E.g.: 'bitcoincash'.
|
||||
* @param {Uint8Array} payload Array of 5-bit integers containing the address' payload.
|
||||
@@ -9011,6 +9011,21 @@ function toCashAddress (address) {
|
||||
return encodeAsCashaddr(decoded)
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given address into SLP format.
|
||||
* @static
|
||||
* @param {string} address - A valid SLP address in any format.
|
||||
* @return {string}
|
||||
* @throws {InvalidAddressError}
|
||||
*/
|
||||
function toSlpAddress (address) {
|
||||
var decoded = decodeAddress(address)
|
||||
return encodeAsSlpaddr(decoded)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Version byte table for base58 formats.
|
||||
* @private
|
||||
@@ -9125,7 +9140,7 @@ function decodeCashAddress (address) {
|
||||
} catch (error) {
|
||||
}
|
||||
} else {
|
||||
var prefixes = ['bitcoincash', 'bchtest', 'regtest']
|
||||
var prefixes = ['bitcoincash', 'bchtest', 'regtest', 'simpleledger', 'slptest']
|
||||
for (var i = 0; i < prefixes.length; ++i) {
|
||||
try {
|
||||
var prefix = prefixes[i]
|
||||
@@ -9151,6 +9166,7 @@ function decodeCashAddressWithPrefix (address) {
|
||||
var type = decoded.type === 'P2PKH' ? Type.P2PKH : Type.P2SH
|
||||
switch (decoded.prefix) {
|
||||
case 'bitcoincash':
|
||||
case 'simpleledger':
|
||||
return {
|
||||
hash: hash,
|
||||
format: Format.Cashaddr,
|
||||
@@ -9158,6 +9174,7 @@ function decodeCashAddressWithPrefix (address) {
|
||||
type: type
|
||||
}
|
||||
case 'bchtest':
|
||||
case 'slptest':
|
||||
case 'regtest':
|
||||
return {
|
||||
hash: hash,
|
||||
@@ -9212,6 +9229,19 @@ function encodeAsCashaddr (decoded) {
|
||||
return cashaddr.encode(prefix, type, hash)
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the given decoded address into slp addr format.
|
||||
* @private
|
||||
* @param {object} decoded
|
||||
* @returns {string}
|
||||
*/
|
||||
function encodeAsSlpaddr (decoded) {
|
||||
var prefix = decoded.network === Network.Mainnet ? 'simpleledger' : 'slptest'
|
||||
var type = decoded.type === Type.P2PKH ? 'P2PKH' : 'P2SH'
|
||||
var hash = Uint8Array.from(decoded.hash)
|
||||
return cashaddr.encode(prefix, type, hash)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether the address is in legacy format.
|
||||
* @static
|
||||
@@ -9313,6 +9343,7 @@ module.exports = {
|
||||
toLegacyAddress: toLegacyAddress,
|
||||
toBitpayAddress: toBitpayAddress,
|
||||
toCashAddress: toCashAddress,
|
||||
toSlpAddress: toSlpAddress,
|
||||
isLegacyAddress: isLegacyAddress,
|
||||
isBitpayAddress: isBitpayAddress,
|
||||
isCashAddress: isCashAddress,
|
||||
@@ -9325,4 +9356,4 @@ module.exports = {
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"bs58check":7,"buffer":8,"cashaddrjs":10}]},{},[52])(52)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8596,13 +8596,13 @@ module.exports={
|
||||
"OP_CHECKMULTISIGVERIFY": 175,
|
||||
|
||||
"OP_NOP1": 176,
|
||||
|
||||
|
||||
"OP_NOP2": 177,
|
||||
"OP_CHECKLOCKTIMEVERIFY": 177,
|
||||
|
||||
"OP_NOP3": 178,
|
||||
"OP_CHECKSEQUENCEVERIFY": 178,
|
||||
|
||||
|
||||
"OP_NOP4": 179,
|
||||
"OP_NOP5": 180,
|
||||
"OP_NOP6": 181,
|
||||
@@ -15165,4 +15165,4 @@ module.exports = {
|
||||
|
||||
}).call(this,require("buffer").Buffer)
|
||||
},{"bs58check":83,"buffer":5}]},{},[34])(34)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18123,7 +18123,7 @@ module.exports = function privateDecrypt(private_key, enc, reverse) {
|
||||
} else {
|
||||
padding = 4;
|
||||
}
|
||||
|
||||
|
||||
var key = parseKeys(private_key);
|
||||
var k = key.modulus.byteLength();
|
||||
if (enc.length > k || new bn(enc).cmp(key.modulus) >= 0) {
|
||||
@@ -22690,13 +22690,13 @@ Script.prototype.runInContext = function (context) {
|
||||
if (!(context instanceof Context)) {
|
||||
throw new TypeError("needs a 'context' argument.");
|
||||
}
|
||||
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
if (!iframe.style) iframe.style = {};
|
||||
iframe.style.display = 'none';
|
||||
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
|
||||
var win = iframe.contentWindow;
|
||||
var wEval = win.eval, wExecScript = win.execScript;
|
||||
|
||||
@@ -22705,7 +22705,7 @@ Script.prototype.runInContext = function (context) {
|
||||
wExecScript.call(win, 'null');
|
||||
wEval = win.eval;
|
||||
}
|
||||
|
||||
|
||||
forEach(Object_keys(context), function (key) {
|
||||
win[key] = context[key];
|
||||
});
|
||||
@@ -22714,11 +22714,11 @@ Script.prototype.runInContext = function (context) {
|
||||
win[key] = context[key];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var winKeys = Object_keys(win);
|
||||
|
||||
var res = wEval.call(win, this.code);
|
||||
|
||||
|
||||
forEach(Object_keys(win), function (key) {
|
||||
// Avoid copying circular objects like `top` and `window` by only
|
||||
// updating existing context properties or new properties in the `win`
|
||||
@@ -22733,9 +22733,9 @@ Script.prototype.runInContext = function (context) {
|
||||
defineProp(context, key, win[key]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.body.removeChild(iframe);
|
||||
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -27914,4 +27914,4 @@ Sha512.prototype._hash = function () {
|
||||
module.exports = Sha512
|
||||
|
||||
},{"./hash":195,"inherits":189,"safe-buffer":193}]},{},[150])(150)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ bitcoinjs.bitcoin.networks.clam = {
|
||||
private: 0xa8c17826
|
||||
},
|
||||
pubKeyHash: 0x89,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
scriptHash: 0x0D,
|
||||
wif: 0x85
|
||||
};
|
||||
|
||||
@@ -39,7 +39,27 @@ bitcoinjs.bitcoin.networks.crown = {
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
wif: 0x80,
|
||||
toNewAddress: function(oldAddress)
|
||||
{
|
||||
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||
var b58 = basex(ALPHABET);
|
||||
|
||||
var addrBytes = b58.decode(oldAddress);
|
||||
|
||||
var hash160 = new Uint16Array(23);
|
||||
hash160[0]= 0x01; //C
|
||||
hash160[1]= 0x75; //R
|
||||
hash160[2]= 0x07; //W
|
||||
addrBytes.copy(hash160, 3, 1, 21);
|
||||
|
||||
var checksum = bitcoinjs.bitcoin.crypto.hash256(hash160).subarray(0, 4);
|
||||
var binaryAddr = new Uint16Array(27);
|
||||
binaryAddr.set(hash160,0);
|
||||
checksum.copy(binaryAddr, 23, 0, 4);
|
||||
var newAddress = b58.encode(binaryAddr);
|
||||
return newAddress;
|
||||
}
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dash = {
|
||||
@@ -93,7 +113,7 @@ bitcoinjs.bitcoin.networks.namecoin = {
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x34,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
scriptHash: 0x0D,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
@@ -104,7 +124,7 @@ bitcoinjs.bitcoin.networks.peercoin = {
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x37,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
scriptHash: 0x75,
|
||||
wif: 0xb7
|
||||
};
|
||||
|
||||
@@ -152,6 +172,17 @@ bitcoinjs.bitcoin.networks.dogecoin = {
|
||||
wif: 0x9e
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet = {
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.denarius = {
|
||||
messagePrefix: '\x19Denarius Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -236,20 +267,42 @@ bitcoinjs.bitcoin.networks.myriadcoin = {
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x00, // TODO set this correctly
|
||||
scriptHash: 0x09,
|
||||
wif: 0xb2
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bolivarcoin = {
|
||||
messagePrefix: 'Bolivarcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x55,
|
||||
scriptHash: 0x05,
|
||||
wif: 0xD5
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.onixcoin = {
|
||||
messagePrefix: 'unused',
|
||||
messagePrefix: 'ONIX Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x4B,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
wif: 0xCB
|
||||
};
|
||||
|
||||
|
||||
bitcoinjs.bitcoin.networks.lkrcoin = {
|
||||
messagePrefix: '\x18LKRcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x30,
|
||||
scriptHash: 0x55,
|
||||
wif: 0xB0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.pivx = {
|
||||
@@ -274,6 +327,28 @@ bitcoinjs.bitcoin.networks.pivxtestnet = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fix = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x022d2533,
|
||||
private: 0x0221312b
|
||||
},
|
||||
pubKeyHash: 0x23,
|
||||
scriptHash: 0x5F,
|
||||
wif: 0x3C
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fixtestnet = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x3a8061a0,
|
||||
private: 0x3a805837
|
||||
},
|
||||
pubKeyHash: 0x4c,
|
||||
scriptHash: 0x89,
|
||||
wif: 0xED
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.fujicoin = {
|
||||
messagePrefix: '\x19FujiCoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -573,7 +648,7 @@ bitcoinjs.bitcoin.networks.diamond = {
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.digibyte = {
|
||||
messagePrefix: '\x18DigiByte Signed Message:\n',
|
||||
messagePrefix: '\x19DigiByte Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
@@ -726,6 +801,28 @@ bitcoinjs.bitcoin.networks.gridcoin = {
|
||||
wif: 0xbe,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcoin = {
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 36,
|
||||
scriptHash: 5,
|
||||
wif: 128,
|
||||
}
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcointestnet = {
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef,
|
||||
}
|
||||
|
||||
bitcoinjs.bitcoin.networks.gulden = {
|
||||
messagePrefix: '\x18Guldencoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -836,6 +933,17 @@ bitcoinjs.bitcoin.networks.linx = {
|
||||
wif: 0xcb,
|
||||
};
|
||||
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecointestnet = {
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394,
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef,
|
||||
};
|
||||
bitcoinjs.bitcoin.networks.litecoincash = {
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -902,6 +1010,17 @@ bitcoinjs.bitcoin.networks.neoscoin = {
|
||||
wif: 0xb1,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.nix = {
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x35,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.neurocoin = {
|
||||
messagePrefix: '\x18PPCoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1023,6 +1142,17 @@ bitcoinjs.bitcoin.networks.putincoin = {
|
||||
wif: 0xb7,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.ravencoin = {
|
||||
messagePrefix: '\x16Raven Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x3c,
|
||||
scriptHash: 0x7a,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.reddcoin = {
|
||||
messagePrefix: '\x18Reddcoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1056,6 +1186,17 @@ bitcoinjs.bitcoin.networks.rubycoin = {
|
||||
wif: 0xbc,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.safecoin = {
|
||||
messagePrefix: '\x18Safecoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x3d,
|
||||
scriptHash: 0x56,
|
||||
wif: 0xbd,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.salus = {
|
||||
messagePrefix: '\x18Salus Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1156,6 +1297,28 @@ bitcoinjs.bitcoin.networks.toa = {
|
||||
wif: 0xc1,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.twins = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x022d2533,
|
||||
private: 0x0221312b
|
||||
},
|
||||
pubKeyHash: 0x49,
|
||||
scriptHash: 0x53,
|
||||
wif: 0x42
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.twinstestnet = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x3a8061a0,
|
||||
private: 0x3a805837
|
||||
},
|
||||
pubKeyHash: 0x4c,
|
||||
scriptHash: 0x89,
|
||||
wif: 0xED
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.ultimatesecurecash = {
|
||||
messagePrefix: '\x18UltimateSecureCash Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1321,6 +1484,17 @@ bitcoinjs.bitcoin.networks.hush = {
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.hush3 = {
|
||||
messagePrefix: '\x18Hush Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x3C,
|
||||
scriptHash: 0x55,
|
||||
wif: 0xBC,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.zclassic = {
|
||||
messagePrefix: '\x18Zcash Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1407,4 +1581,160 @@ bitcoinjs.bitcoin.networks.projectcoin = {
|
||||
pubKeyHash: 0x37,
|
||||
scriptHash: 0x08,
|
||||
wif: 0x75,
|
||||
};
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.phore = {
|
||||
messagePrefix: '\x18Phore Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x022D2533,
|
||||
private: 0x0221312B,
|
||||
},
|
||||
pubKeyHash: 0x37,
|
||||
scriptHash: 0x0D,
|
||||
wif: 0xD4,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blocknode = {
|
||||
messagePrefix: '\x18Blocknode Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x19,
|
||||
scriptHash: 0x3F,
|
||||
wif: 0x4b,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blocknode_testnet = {
|
||||
messagePrefix: '\x18Blocknode Testnet Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x55,
|
||||
scriptHash: 0x7d,
|
||||
wif: 0x89,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecoinz = {
|
||||
messagePrefix: '\x18LitecoinZ Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE3,
|
||||
},
|
||||
pubKeyHash: 0x0AB3,
|
||||
scriptHash: 0x0AB8,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blockstamp = {
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.deeponion = {
|
||||
messagePrefix: 'x18DeepOnion Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x1F,
|
||||
scriptHash: 0x4E,
|
||||
wif: 0x9F,
|
||||
};
|
||||
|
||||
|
||||
bitcoinjs.bitcoin.networks.cpuchain = {
|
||||
messagePrefix: 'x18CPUchain Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x1C,
|
||||
scriptHash: 0x1E,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.wagerr = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x022d2533,
|
||||
private: 0x0221312b
|
||||
},
|
||||
pubKeyHash: 0x49,
|
||||
scriptHash: 0x3f,
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcoinsv = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monkeyproject = {
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488dde4
|
||||
},
|
||||
pubKeyHash: 0x33,
|
||||
scriptHash: 0x1c,
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.rapids = {
|
||||
messagePrefix: 'DarkNet Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x3d,
|
||||
scriptHash: 0x06,
|
||||
wif: 0x2e
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.aryacoin = {
|
||||
messagePrefix: '\x18Aryacoin Signed Message:\n',
|
||||
bech32: 'arya',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x17,
|
||||
scriptHash: 0x6f,
|
||||
wif: 0x97
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.thought = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0xFbC6A00D,
|
||||
private: 0x5AEBD8C6
|
||||
},
|
||||
pubKeyHash: 0x07,
|
||||
scriptHash: 0x09,
|
||||
wif: 0x7B
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.elastos = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x21,
|
||||
scriptHash: 0xc4, // TODO set this correctly, same as BTC for now
|
||||
wif: 0xef // TODO set this correctly, same as BTC for now
|
||||
};
|
||||
|
||||
9
src/js/casinocoin-util.js
Normal file
9
src/js/casinocoin-util.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function convertCasinoCoinAdrr(address) {
|
||||
return window.basex('cpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2brdeCg65jkm8oFqi1tuvAxyz').encode(
|
||||
window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertCasinoCoinPriv(priv) {
|
||||
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
69
src/js/elastos-1.0.9.min.js
vendored
Normal file
69
src/js/elastos-1.0.9.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7414
src/js/eos-util.js
Normal file
7414
src/js/eos-util.js
Normal file
File diff suppressed because it is too large
Load Diff
17951
src/js/groestlcoinjs-3.3.2.js
Normal file
17951
src/js/groestlcoinjs-3.3.2.js
Normal file
File diff suppressed because it is too large
Load Diff
28732
src/js/groestlcoinjs-bip38-2.0.2.js
Normal file
28732
src/js/groestlcoinjs-bip38-2.0.2.js
Normal file
File diff suppressed because it is too large
Load Diff
623
src/js/index.js
623
src/js/index.js
@@ -44,6 +44,8 @@
|
||||
DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning");
|
||||
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
|
||||
DOM.phrase = $(".phrase");
|
||||
DOM.phraseSplit = $(".phraseSplit");
|
||||
DOM.phraseSplitWarn = $(".phraseSplitWarn");
|
||||
DOM.passphrase = $(".passphrase");
|
||||
DOM.generateContainer = $(".generate-container");
|
||||
DOM.generate = $(".generate");
|
||||
@@ -232,7 +234,14 @@
|
||||
if (phraseChangeTimeoutEvent != null) {
|
||||
clearTimeout(phraseChangeTimeoutEvent);
|
||||
}
|
||||
phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
|
||||
phraseChangeTimeoutEvent = setTimeout(function() {
|
||||
phraseChanged();
|
||||
var entropy = mnemonic.toRawEntropyBin(DOM.phrase.val());
|
||||
if (entropy !== null) {
|
||||
DOM.entropyMnemonicLength.val("raw");
|
||||
DOM.entropy.val(entropy);
|
||||
}
|
||||
}, 400);
|
||||
}
|
||||
|
||||
function phraseChanged() {
|
||||
@@ -251,6 +260,7 @@
|
||||
calcForDerivationPath();
|
||||
// Show the word indexes
|
||||
showWordIndexes();
|
||||
writeSplitPhrase(phrase);
|
||||
}
|
||||
|
||||
function tabChanged() {
|
||||
@@ -297,6 +307,7 @@
|
||||
clearDisplay();
|
||||
clearEntropyFeedback();
|
||||
DOM.phrase.val("");
|
||||
DOM.phraseSplit.val("");
|
||||
showValidationError("Blank entropy");
|
||||
return;
|
||||
}
|
||||
@@ -331,6 +342,7 @@
|
||||
showPending();
|
||||
// Clear existing mnemonic and passphrase
|
||||
DOM.phrase.val("");
|
||||
DOM.phraseSplit.val("");
|
||||
DOM.passphrase.val("");
|
||||
seed = null;
|
||||
if (rootKeyChangedTimeoutEvent != null) {
|
||||
@@ -488,9 +500,16 @@
|
||||
function calcBip32RootKeyFromSeed(phrase, passphrase) {
|
||||
seed = mnemonic.toSeed(phrase, passphrase);
|
||||
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network);
|
||||
if(isGRS())
|
||||
bip32RootKey = groestlcoinjs.HDNode.fromSeedHex(seed, network);
|
||||
|
||||
}
|
||||
|
||||
function calcBip32RootKeyFromBase58(rootKeyBase58) {
|
||||
if(isGRS()) {
|
||||
calcBip32RootKeyFromBase58GRS(rootKeyBase58);
|
||||
return;
|
||||
}
|
||||
// try parsing with various segwit network params since this extended
|
||||
// key may be from any one of them.
|
||||
if (networkHasSegwit()) {
|
||||
@@ -525,6 +544,41 @@
|
||||
bip32RootKey = bitcoinjs.bitcoin.HDNode.fromBase58(rootKeyBase58, network);
|
||||
}
|
||||
|
||||
function calcBip32RootKeyFromBase58GRS(rootKeyBase58) {
|
||||
// try parsing with various segwit network params since this extended
|
||||
// key may be from any one of them.
|
||||
if (networkHasSegwit()) {
|
||||
var n = network;
|
||||
if ("baseNetwork" in n) {
|
||||
n = bitcoinjs.bitcoin.networks[n.baseNetwork];
|
||||
}
|
||||
// try parsing using base network params
|
||||
try {
|
||||
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
|
||||
return;
|
||||
}
|
||||
catch (e) {}
|
||||
// try parsing using p2wpkh params
|
||||
if ("p2wpkh" in n) {
|
||||
try {
|
||||
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
|
||||
return;
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
// try parsing using p2wpkh-in-p2sh network params
|
||||
if ("p2wpkhInP2sh" in n) {
|
||||
try {
|
||||
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
|
||||
return;
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
// try the network params as currently specified
|
||||
bip32RootKey = groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
|
||||
}
|
||||
|
||||
function calcBip32ExtendedKey(path) {
|
||||
// Check there's a root key to derive from
|
||||
if (!bip32RootKey) {
|
||||
@@ -552,7 +606,7 @@
|
||||
extendedKey = extendedKey.derive(index);
|
||||
}
|
||||
}
|
||||
return extendedKey
|
||||
return extendedKey;
|
||||
}
|
||||
|
||||
function showValidationError(errorText) {
|
||||
@@ -595,6 +649,9 @@
|
||||
}
|
||||
|
||||
function validateRootKey(rootKeyBase58) {
|
||||
if(isGRS())
|
||||
return validateRootKeyGRS(rootKeyBase58);
|
||||
|
||||
// try various segwit network params since this extended key may be from
|
||||
// any one of them.
|
||||
if (networkHasSegwit()) {
|
||||
@@ -635,6 +692,47 @@
|
||||
return "";
|
||||
}
|
||||
|
||||
function validateRootKeyGRS(rootKeyBase58) {
|
||||
// try various segwit network params since this extended key may be from
|
||||
// any one of them.
|
||||
if (networkHasSegwit()) {
|
||||
var n = network;
|
||||
if ("baseNetwork" in n) {
|
||||
n = bitcoinjs.bitcoin.networks[n.baseNetwork];
|
||||
}
|
||||
// try parsing using base network params
|
||||
try {
|
||||
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n);
|
||||
return "";
|
||||
}
|
||||
catch (e) {}
|
||||
// try parsing using p2wpkh params
|
||||
if ("p2wpkh" in n) {
|
||||
try {
|
||||
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkh);
|
||||
return "";
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
// try parsing using p2wpkh-in-p2sh network params
|
||||
if ("p2wpkhInP2sh" in n) {
|
||||
try {
|
||||
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, n.p2wpkhInP2sh);
|
||||
return "";
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
// try the network params as currently specified
|
||||
try {
|
||||
groestlcoinjs.HDNode.fromBase58(rootKeyBase58, network);
|
||||
}
|
||||
catch (e) {
|
||||
return "Invalid root key";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function getDerivationPath() {
|
||||
if (bip44TabSelected()) {
|
||||
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
|
||||
@@ -745,6 +843,14 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function isGRS() {
|
||||
return networks[DOM.network.val()].name == "GRS - Groestlcoin" || networks[DOM.network.val()].name == "GRS - Groestlcoin Testnet";
|
||||
}
|
||||
|
||||
function isELA() {
|
||||
return networks[DOM.network.val()].name == "ELA - Elastos"
|
||||
}
|
||||
|
||||
function displayBip44Info() {
|
||||
// Get the derivation path for the account
|
||||
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
|
||||
@@ -758,9 +864,14 @@
|
||||
var accountExtendedKey = calcBip32ExtendedKey(path);
|
||||
var accountXprv = accountExtendedKey.toBase58();
|
||||
var accountXpub = accountExtendedKey.neutered().toBase58();
|
||||
|
||||
// Display the extended keys
|
||||
DOM.bip44accountXprv.val(accountXprv);
|
||||
DOM.bip44accountXpub.val(accountXpub);
|
||||
|
||||
if (isELA()) {
|
||||
displayBip44InfoForELA();
|
||||
}
|
||||
}
|
||||
|
||||
function displayBip49Info() {
|
||||
@@ -816,6 +927,10 @@
|
||||
clearAddressesList();
|
||||
var initialAddressCount = parseInt(DOM.rowsToAdd.val());
|
||||
displayAddresses(0, initialAddressCount);
|
||||
|
||||
if (isELA()) {
|
||||
displayBip32InfoForELA();
|
||||
}
|
||||
}
|
||||
|
||||
function displayAddresses(start, total) {
|
||||
@@ -888,6 +1003,9 @@
|
||||
var useUncompressed = useBip38;
|
||||
if (useUncompressed) {
|
||||
keyPair = new bitcoinjs.bitcoin.ECPair(keyPair.d, null, { network: network, compressed: false });
|
||||
if(isGRS())
|
||||
keyPair = new groestlcoinjs.ECPair(keyPair.d, null, { network: network, compressed: false });
|
||||
|
||||
}
|
||||
// get address
|
||||
var address = keyPair.getAddress().toString();
|
||||
@@ -898,9 +1016,14 @@
|
||||
privkey = keyPair.toWIF();
|
||||
// BIP38 encode private key if required
|
||||
if (useBip38) {
|
||||
privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
|
||||
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
|
||||
});
|
||||
if(isGRS())
|
||||
privkey = groestlcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
|
||||
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
|
||||
}, null, networks[DOM.network.val()].name.includes("Testnet"));
|
||||
else
|
||||
privkey = bitcoinjsBip38.encrypt(keyPair.d.toBuffer(), false, bip38password, function(p) {
|
||||
console.log("Progressed " + p.percent.toFixed(1) + "% for index " + index);
|
||||
});
|
||||
}
|
||||
}
|
||||
// get pubkey
|
||||
@@ -910,14 +1033,7 @@
|
||||
indexText = indexText + "'";
|
||||
}
|
||||
// Ethereum values are different
|
||||
if ((networks[DOM.network.val()].name == "ETH - Ethereum")
|
||||
|| (networks[DOM.network.val()].name == "ETC - Ethereum Classic")
|
||||
|| (networks[DOM.network.val()].name == "PIRL - Pirl")
|
||||
|| (networks[DOM.network.val()].name == "MIX - MIX")
|
||||
|| (networks[DOM.network.val()].name == "MUSIC - Musicoin")
|
||||
|| (networks[DOM.network.val()].name == "POA - Poa")
|
||||
|| (networks[DOM.network.val()].name == "EXP - Expanse")
|
||||
|| (networks[DOM.network.val()].name == "CLO - Callisto")) {
|
||||
if (networkIsEthereum()) {
|
||||
var privKeyBuffer = keyPair.d.toBuffer(32);
|
||||
privkey = privKeyBuffer.toString('hex');
|
||||
var addressBuffer = ethUtil.privateToAddress(privKeyBuffer);
|
||||
@@ -927,11 +1043,38 @@
|
||||
privkey = ethUtil.addHexPrefix(privkey);
|
||||
pubkey = ethUtil.addHexPrefix(pubkey);
|
||||
}
|
||||
|
||||
// Stellar is different
|
||||
if (networks[DOM.network.val()].name == "XLM - Stellar") {
|
||||
var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
|
||||
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
|
||||
var path = "m/";
|
||||
path += purpose + "'/";
|
||||
path += coin + "'/" + index + "'";
|
||||
var keypair = stellarUtil.getKeypair(path, seed);
|
||||
indexText = path;
|
||||
privkey = keypair.secret();
|
||||
pubkey = address = keypair.publicKey();
|
||||
}
|
||||
if ((networks[DOM.network.val()].name == "NAS - Nebulas")) {
|
||||
var NasAccount = require("nebulas-account");
|
||||
var privKeyBuffer = keyPair.d.toBuffer(32);
|
||||
var nebulasAccount = new NasAccount();
|
||||
nebulasAccount.setPrivateKey(privKeyBuffer);
|
||||
address = nebulasAccount.getAddressString();
|
||||
privkey = nebulasAccount.getPrivateKeyString();
|
||||
pubkey = nebulasAccount.getPublicKeyString();
|
||||
}
|
||||
// Ripple values are different
|
||||
if (networks[DOM.network.val()].name == "XRP - Ripple") {
|
||||
privkey = convertRipplePriv(privkey);
|
||||
address = convertRippleAdrr(address);
|
||||
}
|
||||
// CasinoCoin values are different
|
||||
if (networks[DOM.network.val()].name == "CSC - CasinoCoin") {
|
||||
privkey = convertCasinoCoinPriv(privkey);
|
||||
address = convertCasinoCoinAdrr(address);
|
||||
}
|
||||
// Bitcoin Cash address format may vary
|
||||
if (networks[DOM.network.val()].name == "BCH - Bitcoin Cash") {
|
||||
var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
|
||||
@@ -942,6 +1085,13 @@
|
||||
address = bchaddr.toBitpayAddress(address);
|
||||
}
|
||||
}
|
||||
// Bitcoin Cash address format may vary
|
||||
if (networks[DOM.network.val()].name == "SLP - Simple Ledger Protocol") {
|
||||
var bchAddrType = DOM.bitcoinCashAddressType.filter(":checked").val();
|
||||
if (bchAddrType == "cashaddr") {
|
||||
address = bchaddr.toSlpAddress(address);
|
||||
}
|
||||
}
|
||||
// Segwit addresses are different
|
||||
if (isSegwit) {
|
||||
if (!segwitAvailable) {
|
||||
@@ -960,6 +1110,47 @@
|
||||
address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network)
|
||||
}
|
||||
}
|
||||
|
||||
if ((networks[DOM.network.val()].name == "CRW - Crown")) {
|
||||
address = bitcoinjs.bitcoin.networks.crown.toNewAddress(address);
|
||||
}
|
||||
|
||||
if (networks[DOM.network.val()].name == "EOS - EOSIO") {
|
||||
address = ""
|
||||
pubkey = eosUtil.bufferToPublic(keyPair.getPublicKeyBuffer());
|
||||
privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
|
||||
}
|
||||
|
||||
//Groestlcoin Addresses are different
|
||||
if(isGRS()) {
|
||||
|
||||
if (isSegwit) {
|
||||
if (!segwitAvailable) {
|
||||
return;
|
||||
}
|
||||
if (isP2wpkh) {
|
||||
address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
|
||||
}
|
||||
else if (isP2wpkhInP2sh) {
|
||||
address = groestlcoinjs.address.fromOutputScript(scriptpubkey, network)
|
||||
}
|
||||
}
|
||||
//non-segwit addresses are handled by using groestlcoinjs for bip32RootKey
|
||||
}
|
||||
|
||||
if (isELA()) {
|
||||
let elaAddress = calcAddressForELA(
|
||||
seed,
|
||||
parseIntNoNaN(DOM.bip44coin.val(), 0),
|
||||
parseIntNoNaN(DOM.bip44account.val(), 0),
|
||||
parseIntNoNaN(DOM.bip44change.val(), 0),
|
||||
index
|
||||
);
|
||||
address = elaAddress.address;
|
||||
privkey = elaAddress.privateKey;
|
||||
pubkey = elaAddress.publicKey;
|
||||
}
|
||||
|
||||
addAddressToList(indexText, address, pubkey, privkey);
|
||||
if (isLast) {
|
||||
hidePending();
|
||||
@@ -1251,6 +1442,49 @@
|
||||
return phrase;
|
||||
}
|
||||
|
||||
function writeSplitPhrase(phrase) {
|
||||
var wordCount = phrase.split(/\s/g).length;
|
||||
var left=[];
|
||||
for (var i=0;i<wordCount;i++) left.push(i);
|
||||
var group=[[],[],[]],
|
||||
groupI=-1;
|
||||
var seed = Math.abs(sjcl.hash.sha256.hash(phrase)[0])% 2147483647;
|
||||
while (left.length>0) {
|
||||
groupI=(groupI+1)%3;
|
||||
seed = seed * 16807 % 2147483647;
|
||||
var selected=Math.floor(left.length*(seed - 1) / 2147483646);
|
||||
group[groupI].push(left[selected]);
|
||||
left.splice(selected,1);
|
||||
}
|
||||
var cards=[phrase.split(/\s/g),phrase.split(/\s/g),phrase.split(/\s/g)];
|
||||
for (var i=0;i<3;i++) {
|
||||
for (var ii=0;ii<wordCount/3;ii++) cards[i][group[i][ii]]='XXXX';
|
||||
cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]);
|
||||
}
|
||||
DOM.phraseSplit.val(cards.join("\r\n"));
|
||||
var triesPerSecond=10000000000;
|
||||
var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond;
|
||||
var displayRedText = false;
|
||||
if (hackTime<1) {
|
||||
hackTime="<1 second";
|
||||
displayRedText = true;
|
||||
} else if (hackTime<86400) {
|
||||
hackTime=Math.floor(hackTime)+" seconds";
|
||||
displayRedText = true;
|
||||
} else if(hackTime<31557600) {
|
||||
hackTime=Math.floor(hackTime/86400)+" days";
|
||||
displayRedText = true;
|
||||
} else {
|
||||
hackTime=Math.floor(hackTime/31557600)+" years";
|
||||
}
|
||||
DOM.phraseSplitWarn.html("Time to hack with only one card: "+hackTime);
|
||||
if (displayRedText) {
|
||||
DOM.phraseSplitWarn.addClass("text-danger");
|
||||
} else {
|
||||
DOM.phraseSplitWarn.removeClass("text-danger");
|
||||
}
|
||||
}
|
||||
|
||||
function isUsingOwnEntropy() {
|
||||
return DOM.useEntropy.prop("checked");
|
||||
}
|
||||
@@ -1308,6 +1542,7 @@
|
||||
var phrase = mnemonic.toMnemonic(entropyArr);
|
||||
// Set the mnemonic in the UI
|
||||
DOM.phrase.val(phrase);
|
||||
writeSplitPhrase(phrase);
|
||||
// Show the word indexes
|
||||
showWordIndexes();
|
||||
// Show the checksum
|
||||
@@ -1471,6 +1706,23 @@
|
||||
return DOM.bip32tab.hasClass("active");
|
||||
}
|
||||
|
||||
function networkIsEthereum() {
|
||||
var name = networks[DOM.network.val()].name;
|
||||
return (name == "ETH - Ethereum")
|
||||
|| (name == "ETC - Ethereum Classic")
|
||||
|| (name == "EWT - EnergyWeb")
|
||||
|| (name == "PIRL - Pirl")
|
||||
|| (name == "MIX - MIX")
|
||||
|| (name == "MUSIC - Musicoin")
|
||||
|| (name == "POA - Poa")
|
||||
|| (name == "EXP - Expanse")
|
||||
|| (name == "CLO - Callisto")
|
||||
|| (name == "DXN - DEXON")
|
||||
|| (name == "ELLA - Ellaism")
|
||||
|| (name == "ESN - Ethersocial Network")
|
||||
|| (name == "VET - VeChain")
|
||||
}
|
||||
|
||||
function networkHasSegwit() {
|
||||
var n = network;
|
||||
if ("baseNetwork" in network) {
|
||||
@@ -1646,6 +1898,13 @@
|
||||
setHdCoin(161);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ARYA - Aryacoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.aryacoin;
|
||||
setHdCoin(357);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AUR - Auroracoin",
|
||||
onSelect: function() {
|
||||
@@ -1659,14 +1918,21 @@
|
||||
network = bitcoinjs.bitcoin.networks.axe;
|
||||
setHdCoin(4242);
|
||||
},
|
||||
},
|
||||
{
|
||||
},
|
||||
{
|
||||
name: "ANON - ANON",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.anon;
|
||||
setHdCoin(220);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BOLI - Bolivarcoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bolivarcoin;
|
||||
setHdCoin(278);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BCA - Bitcoin Atom",
|
||||
onSelect: function() {
|
||||
@@ -1702,6 +1968,20 @@
|
||||
setHdCoin(10);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BND - Blocknode",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.blocknode;
|
||||
setHdCoin(2941);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tBND - Blocknode Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.blocknode_testnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BRIT - Britcoin",
|
||||
onSelect: function() {
|
||||
@@ -1716,6 +1996,13 @@
|
||||
setHdCoin(91);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BST - BlockStamp",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.blockstamp;
|
||||
setHdCoin(254);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BTA - Bata",
|
||||
onSelect: function() {
|
||||
@@ -1737,7 +2024,7 @@
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "BITG - Bitcoin Green",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoingreen;
|
||||
@@ -1751,6 +2038,13 @@
|
||||
setHdCoin(183);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BSV - BitcoinSV",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoinsv;
|
||||
setHdCoin(236);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "BTCZ - Bitcoinz",
|
||||
onSelect: function() {
|
||||
@@ -1829,6 +2123,13 @@
|
||||
setHdCoin(71);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CPU - CPUchain",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.cpuchain;
|
||||
setHdCoin(363);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CRAVE - Crave",
|
||||
onSelect: function() {
|
||||
@@ -1836,6 +2137,13 @@
|
||||
setHdCoin(186);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CRW - Crown (Legacy)",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.crown;
|
||||
setHdCoin(72);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CRW - Crown",
|
||||
onSelect: function() {
|
||||
@@ -1843,6 +2151,13 @@
|
||||
setHdCoin(72);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CSC - CasinoCoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(359);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "DASH - Dash",
|
||||
onSelect: function() {
|
||||
@@ -1899,6 +2214,20 @@
|
||||
setHdCoin(3);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "DOGEt - Dogecoin Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.dogecointestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "DXN - DEXON",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(237);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ECN - Ecoin",
|
||||
onSelect: function() {
|
||||
@@ -1920,6 +2249,21 @@
|
||||
setHdCoin(78);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ELA - Elastos",
|
||||
onSelect: function () {
|
||||
network = bitcoinjs.bitcoin.networks.elastos;
|
||||
setHdCoin(2305);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ELLA - Ellaism",
|
||||
segwitAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(163);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "EMC2 - Einsteinium",
|
||||
onSelect: function() {
|
||||
@@ -1934,6 +2278,21 @@
|
||||
setHdCoin(151);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "EOS - EOSIO",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(194);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ESN - Ethersocial Network",
|
||||
segwitAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(31102);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ETC - Ethereum Classic",
|
||||
segwitAvailable: false,
|
||||
@@ -1948,7 +2307,14 @@
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(60);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "EWT - EnergyWeb",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(246);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "EXCL - Exclusivecoin",
|
||||
onSelect: function() {
|
||||
@@ -1971,6 +2337,20 @@
|
||||
setHdCoin(40);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FIX - FIX",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.fix;
|
||||
setHdCoin(336);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FIX - FIX Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.fixtestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FJC - Fujicoin",
|
||||
onSelect: function() {
|
||||
@@ -2027,6 +2407,20 @@
|
||||
setHdCoin(84);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "GRS - Groestlcoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.groestlcoin;
|
||||
setHdCoin(17);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "GRS - Groestlcoin Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.groestlcointestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HNC - Helleniccoin",
|
||||
onSelect: function() {
|
||||
@@ -2034,13 +2428,20 @@
|
||||
setHdCoin(168);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HUSH - Hush",
|
||||
{
|
||||
name: "HUSH - Hush (Legacy)",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.hush;
|
||||
setHdCoin(197);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HUSH - Hush3",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.hush3;
|
||||
setHdCoin(197);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "INSN - Insane",
|
||||
onSelect: function() {
|
||||
@@ -2113,6 +2514,14 @@
|
||||
setHdCoin(114);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LKR - Lkrcoin",
|
||||
segwitAvailable: false,
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.lkrcoin;
|
||||
setHdCoin(557);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LTC - Litecoin",
|
||||
onSelect: function() {
|
||||
@@ -2121,6 +2530,21 @@
|
||||
DOM.litecoinLtubContainer.removeClass("hidden");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LTCt - Litecoin Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.litecointestnet;
|
||||
setHdCoin(1);
|
||||
DOM.litecoinLtubContainer.removeClass("hidden");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LTZ - LitecoinZ",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.litecoinz;
|
||||
setHdCoin(221);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "LYNX - Lynx",
|
||||
onSelect: function() {
|
||||
@@ -2164,6 +2588,13 @@
|
||||
setHdCoin(22);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MONK - Monkey Project",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.monkeyproject,
|
||||
setHdCoin(214);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MUSIC - Musicoin",
|
||||
segwitAvailable: false,
|
||||
@@ -2179,6 +2610,13 @@
|
||||
setHdCoin(130);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NAS - Nebulas",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(2718);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NEBL - Neblio",
|
||||
onSelect: function() {
|
||||
@@ -2193,6 +2631,13 @@
|
||||
setHdCoin(25);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NIX - NIX Platform",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.nix;
|
||||
setHdCoin(400);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NLG - Gulden",
|
||||
onSelect: function() {
|
||||
@@ -2256,6 +2701,13 @@
|
||||
setHdCoin(200);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ONION - DeepOnion",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.deeponion;
|
||||
setHdCoin(305);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ONX - Onixcoin",
|
||||
onSelect: function() {
|
||||
@@ -2263,6 +2715,13 @@
|
||||
setHdCoin(174);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PHR - Phore",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.phore;
|
||||
setHdCoin(444);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PINK - Pinkcoin",
|
||||
onSelect: function() {
|
||||
@@ -2321,7 +2780,7 @@
|
||||
setHdCoin(6);
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "PRJ - ProjectCoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.projectcoin;
|
||||
@@ -2342,6 +2801,20 @@
|
||||
setHdCoin(122);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "RPD - Rapids",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.rapids;
|
||||
setHdCoin(320);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "RVN - Ravencoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.ravencoin;
|
||||
setHdCoin(175);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "RBY - Rubycoin",
|
||||
onSelect: function() {
|
||||
@@ -2364,6 +2837,13 @@
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SAFE - Safecoin",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.safecoin;
|
||||
setHdCoin(19165);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SLS - Salus",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.salus;
|
||||
@@ -2398,6 +2878,13 @@
|
||||
setHdCoin(111);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SLP - Simple Ledger Protocol",
|
||||
onSelect: function() {
|
||||
DOM.bitcoinCashAddressTypeContainer.removeClass("hidden");
|
||||
setHdCoin(245);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SLR - Solarcoin",
|
||||
onSelect: function() {
|
||||
@@ -2454,6 +2941,13 @@
|
||||
setHdCoin(113);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "THT - Thought",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.thought;
|
||||
setHdCoin(1618);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "TOA - Toa",
|
||||
onSelect: function() {
|
||||
@@ -2461,6 +2955,20 @@
|
||||
setHdCoin(159);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "TWINS - TWINS",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.twins;
|
||||
setHdCoin(970);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "TWINS - TWINS Testnet",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.twinstestnet;
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "USC - Ultimatesecurecash",
|
||||
onSelect: function() {
|
||||
@@ -2489,6 +2997,13 @@
|
||||
setHdCoin(33);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "VET - VeChain",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(818);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "VIA - Viacoin",
|
||||
onSelect: function() {
|
||||
@@ -2517,6 +3032,13 @@
|
||||
setHdCoin(28);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "WGR - Wagerr",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.wagerr;
|
||||
setHdCoin(7825266);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "WC - Wincoin",
|
||||
onSelect: function() {
|
||||
@@ -2524,7 +3046,7 @@
|
||||
setHdCoin(181);
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "XAX - Artax",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.artax;
|
||||
@@ -2538,6 +3060,13 @@
|
||||
setHdCoin(65);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XLM - Stellar",
|
||||
onSelect: function() {
|
||||
network = stellarUtil.dummyNetwork;
|
||||
setHdCoin(148);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XMY - Myriadcoin",
|
||||
onSelect: function() {
|
||||
@@ -2603,7 +3132,7 @@
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ZEN - Zencash",
|
||||
name: "ZEN - Horizen",
|
||||
onSelect: function() {
|
||||
network = bitcoinjs.bitcoin.networks.zencash;
|
||||
setHdCoin(121);
|
||||
@@ -2642,6 +3171,56 @@
|
||||
}
|
||||
]
|
||||
|
||||
// ELA - Elastos functions - begin
|
||||
function displayBip44InfoForELA() {
|
||||
if (!isELA()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
|
||||
var account = parseIntNoNaN(DOM.bip44account.val(), 0);
|
||||
|
||||
// Calculate the account extended keys
|
||||
var accountXprv = elastosjs.getAccountExtendedPrivateKey(seed, coin, account);
|
||||
var accountXpub = elastosjs.getAccountExtendedPublicKey(seed, coin, account);
|
||||
|
||||
// Display the extended keys
|
||||
DOM.bip44accountXprv.val(accountXprv);
|
||||
DOM.bip44accountXpub.val(accountXpub);
|
||||
}
|
||||
|
||||
function displayBip32InfoForELA() {
|
||||
if (!isELA()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
|
||||
var account = parseIntNoNaN(DOM.bip44account.val(), 0);
|
||||
var change = parseIntNoNaN(DOM.bip44change.val(), 0);
|
||||
|
||||
DOM.extendedPrivKey.val(elastosjs.getBip32ExtendedPrivateKey(seed, coin, account, change));
|
||||
DOM.extendedPubKey.val(elastosjs.getBip32ExtendedPublicKey(seed, coin, account, change));
|
||||
|
||||
// Display the addresses and privkeys
|
||||
clearAddressesList();
|
||||
var initialAddressCount = parseInt(DOM.rowsToAdd.val());
|
||||
displayAddresses(0, initialAddressCount);
|
||||
}
|
||||
|
||||
function calcAddressForELA(seed, coin, account, change, index) {
|
||||
if (!isELA()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var publicKey = elastosjs.getDerivedPublicKey(elastosjs.getMasterPublicKey(seed), change, index);
|
||||
return {
|
||||
privateKey: elastosjs.getDerivedPrivateKey(seed, coin, account, change, index),
|
||||
publicKey: publicKey,
|
||||
address: elastosjs.getAddress(publicKey.toString('hex'))
|
||||
};
|
||||
}
|
||||
// ELA - Elastos functions - end
|
||||
|
||||
init();
|
||||
|
||||
})();
|
||||
|
||||
@@ -97,22 +97,10 @@ var Mnemonic = function(language) {
|
||||
}
|
||||
|
||||
self.check = function(mnemonic) {
|
||||
var mnemonic = self.splitWords(mnemonic);
|
||||
if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
|
||||
return false
|
||||
var b = mnemonicToBinaryString(mnemonic);
|
||||
if (b === null) {
|
||||
return false;
|
||||
}
|
||||
// idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
|
||||
var idx = [];
|
||||
for (var i=0; i<mnemonic.length; i++) {
|
||||
var word = mnemonic[i];
|
||||
var wordIndex = wordlist.indexOf(word);
|
||||
if (wordIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
var binaryIndex = zfill(wordIndex.toString(2), 11);
|
||||
idx.push(binaryIndex);
|
||||
}
|
||||
var b = idx.join('');
|
||||
var l = b.length;
|
||||
//d = b[:l / 33 * 32]
|
||||
//h = b[-l / 33:]
|
||||
@@ -128,6 +116,26 @@ var Mnemonic = function(language) {
|
||||
return h == nh;
|
||||
}
|
||||
|
||||
self.toRawEntropyHex = function(mnemonic) {
|
||||
var b = mnemonicToBinaryString(mnemonic);
|
||||
if (b === null)
|
||||
return null;
|
||||
var d = b.substring(0, b.length / 33 * 32);
|
||||
var nd = binaryStringToWordArray(d);
|
||||
|
||||
var h = "";
|
||||
for (var i=0; i<nd.length; i++) {
|
||||
h += ('0000000' + nd[i].toString(16)).slice(-8);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
self.toRawEntropyBin = function(mnemonic) {
|
||||
var b = mnemonicToBinaryString(mnemonic);
|
||||
var d = b.substring(0, b.length / 33 * 32);
|
||||
return d;
|
||||
}
|
||||
|
||||
self.toSeed = function(mnemonic, passphrase) {
|
||||
passphrase = passphrase || '';
|
||||
mnemonic = self.joinWords(self.splitWords(mnemonic)); // removes duplicate blanks
|
||||
@@ -200,6 +208,25 @@ var Mnemonic = function(language) {
|
||||
return a;
|
||||
}
|
||||
|
||||
function mnemonicToBinaryString(mnemonic) {
|
||||
var mnemonic = self.splitWords(mnemonic);
|
||||
if (mnemonic.length == 0 || mnemonic.length % 3 > 0) {
|
||||
return null;
|
||||
}
|
||||
// idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
|
||||
var idx = [];
|
||||
for (var i=0; i<mnemonic.length; i++) {
|
||||
var word = mnemonic[i];
|
||||
var wordIndex = wordlist.indexOf(word);
|
||||
if (wordIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
var binaryIndex = zfill(wordIndex.toString(2), 11);
|
||||
idx.push(binaryIndex);
|
||||
}
|
||||
return idx.join('');
|
||||
}
|
||||
|
||||
// Pad a numeric string on the left with zero digits until the given width
|
||||
// is reached.
|
||||
// Note this differs to the python implementation because it does not
|
||||
|
||||
@@ -1,38 +1,17 @@
|
||||
// source
|
||||
// https://github.com/hiddentao/fast-levenshtein/blob/2.0.6/levenshtein.js
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Extend an Object with another Object's properties.
|
||||
*
|
||||
* The source objects are specified as additional arguments.
|
||||
*
|
||||
* @param dst Object the object to extend.
|
||||
*
|
||||
* @return Object the final object.
|
||||
*/
|
||||
var _extend = function(dst) {
|
||||
var sources = Array.prototype.slice.call(arguments, 1);
|
||||
for (var i=0; i<sources.length; ++i) {
|
||||
var src = sources[i];
|
||||
for (var p in src) {
|
||||
if (src.hasOwnProperty(p)) dst[p] = src[p];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Defer execution of given function.
|
||||
* @param {Function} func
|
||||
*/
|
||||
var _defer = function(func) {
|
||||
if (typeof setImmediate === 'function') {
|
||||
return setImmediate(func);
|
||||
} else {
|
||||
return setTimeout(func, 0);
|
||||
}
|
||||
};
|
||||
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.
|
||||
@@ -43,148 +22,96 @@
|
||||
*
|
||||
* @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) {
|
||||
get: function(str1, str2, options) {
|
||||
var useCollator = (options && collator && options.useCollator);
|
||||
|
||||
var str1Len = str1.length,
|
||||
str2Len = str2.length;
|
||||
|
||||
// base cases
|
||||
if (str1 === str2) return 0;
|
||||
if (str1.length === 0) return str2.length;
|
||||
if (str2.length === 0) return str1.length;
|
||||
if (str1Len === 0) return str2Len;
|
||||
if (str2Len === 0) return str1Len;
|
||||
|
||||
// two rows
|
||||
var prevRow = new Array(str2.length + 1),
|
||||
curCol, nextCol, i, j, tmp;
|
||||
var curCol, nextCol, i, j, tmp;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<prevRow.length; ++i) {
|
||||
for (i=0; i<str2Len; ++i) {
|
||||
prevRow[i] = i;
|
||||
str2Char[i] = str2.charCodeAt(i);
|
||||
}
|
||||
prevRow[str2Len] = str2Len;
|
||||
|
||||
// calculate current row distance from previous row
|
||||
for (i=0; i<str1.length; ++i) {
|
||||
nextCol = i + 1;
|
||||
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<str2.length; ++j) {
|
||||
curCol = nextCol;
|
||||
for (j = 0; j < str2Len; ++j) {
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
// 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 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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronously calculate levenshtein distance of the two strings.
|
||||
*
|
||||
* @param str1 String the first string.
|
||||
* @param str2 String the second string.
|
||||
* @param cb Function callback function with signature: function(Error err, int distance)
|
||||
* @param [options] Object additional options.
|
||||
* @param [options.progress] Function progress callback with signature: function(percentComplete)
|
||||
*/
|
||||
getAsync: function(str1, str2, cb, options) {
|
||||
options = _extend({}, {
|
||||
progress: null
|
||||
}, options);
|
||||
|
||||
// base cases
|
||||
if (str1 === str2) return cb(null, 0);
|
||||
if (str1.length === 0) return cb(null, str2.length);
|
||||
if (str2.length === 0) return cb(null, str1.length);
|
||||
|
||||
// two rows
|
||||
var prevRow = new Array(str2.length + 1),
|
||||
curCol, nextCol,
|
||||
i, j, tmp,
|
||||
startTime, currentTime;
|
||||
|
||||
// initialise previous row
|
||||
for (i=0; i<prevRow.length; ++i) {
|
||||
prevRow[i] = i;
|
||||
}
|
||||
|
||||
nextCol = 1;
|
||||
i = 0;
|
||||
j = -1;
|
||||
|
||||
var __calculate = function() {
|
||||
// reset timer
|
||||
startTime = new Date().valueOf();
|
||||
currentTime = startTime;
|
||||
|
||||
// keep going until one second has elapsed
|
||||
while (currentTime - startTime < 1000) {
|
||||
// reached end of current row?
|
||||
if (str2.length <= (++j)) {
|
||||
// copy current into previous (in preparation for next iteration)
|
||||
prevRow[j] = nextCol;
|
||||
|
||||
// if already done all chars
|
||||
if (str1.length <= (++i)) {
|
||||
return cb(null, nextCol);
|
||||
}
|
||||
// else if we have more left to do
|
||||
else {
|
||||
nextCol = i + 1;
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// calculation
|
||||
curCol = nextCol;
|
||||
|
||||
// substution
|
||||
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 );
|
||||
// insertion
|
||||
tmp = curCol + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
// deletion
|
||||
tmp = prevRow[j + 1] + 1;
|
||||
if (nextCol > tmp) {
|
||||
nextCol = tmp;
|
||||
}
|
||||
|
||||
// copy current into previous (in preparation for next iteration)
|
||||
prevRow[j] = curCol;
|
||||
|
||||
// get current time
|
||||
currentTime = new Date().valueOf();
|
||||
}
|
||||
|
||||
// send a progress update?
|
||||
if (null !== options.progress) {
|
||||
try {
|
||||
options.progress.call(null, (i * 100.0/ str1.length));
|
||||
} catch (err) {
|
||||
return cb('Progress callback: ' + err.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// next iteration
|
||||
_defer(__calculate);
|
||||
};
|
||||
|
||||
__calculate();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
27697
src/js/nebulas-account.js
Normal file
27697
src/js/nebulas-account.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,5 +6,5 @@ function convertRippleAdrr(address) {
|
||||
|
||||
function convertRipplePriv(priv) {
|
||||
return window.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -161,11 +161,11 @@ bitcoinjs.bitcoin.networks.bgold.p2wpkhInP2sh = {
|
||||
|
||||
bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: '\x18DigiByte Signed Message:\n',
|
||||
messagePrefix: 'x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x3f,
|
||||
@@ -173,18 +173,380 @@ bitcoinjs.bitcoin.networks.digibyte.p2wpkh = {
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.digibyte.p2wpkhInP2sh = {
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: '\x18DigiByte Signed Message:\n',
|
||||
baseNetwork: "digibyte",
|
||||
messagePrefix: '\x19DigiByte Signed Message:\n',
|
||||
bech32: 'dgb',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x1e,
|
||||
scriptHash: 0x3f,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
|
||||
|
||||
bitcoinjs.bitcoin.networks.blockstamp.p2wpkh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.blockstamp.p2wpkhInP2sh = {
|
||||
baseNetwork: "blockstamp",
|
||||
messagePrefix: '\x18BlockStamp Signed Message:\n',
|
||||
bech32: 'bc',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x00,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.nix.p2wpkh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x35,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.nix.p2wpkhInP2sh = {
|
||||
baseNetwork: "nix",
|
||||
messagePrefix: '\x18Nix Signed Message:\n',
|
||||
bech32: 'nix',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4,
|
||||
},
|
||||
pubKeyHash: 0x26,
|
||||
scriptHash: 0x35,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.cpuchain.p2wpkh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x1c,
|
||||
scriptHash: 0x1e,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.cpuchain.p2wpkhInP2sh = {
|
||||
baseNetwork: "cpuchain",
|
||||
messagePrefix: '\x1DCPUchain Signed Message:\n',
|
||||
bech32: 'cpu',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x1c,
|
||||
scriptHash: 0x1e,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488dde4
|
||||
},
|
||||
pubKeyHash: 0x33,
|
||||
scriptHash: 0x1c,
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monkeyproject.p2wpkhInP2sh = {
|
||||
baseNetwork: "monkeyproject",
|
||||
messagePrefix: 'Monkey Signed Message:\n',
|
||||
bech32: 'monkey',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488dde4
|
||||
},
|
||||
pubKeyHash: 0x33,
|
||||
scriptHash: 0x1c,
|
||||
wif: 0x37
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.atom.p2wpkh = {
|
||||
baseNetwork: "atom",
|
||||
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
|
||||
bech32: 'atom',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x17,
|
||||
scriptHash: 0x0a,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.atom.p2wpkhInP2sh = {
|
||||
baseNetwork: "atom",
|
||||
messagePrefix: '\x18Bitcoin Atom Signed Message:\n',
|
||||
bech32: 'atom',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x17,
|
||||
scriptHash: 0x0a,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcore.p2wpkh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x03,
|
||||
scriptHash: 0x7D,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
baseNetwork: "bitcore",
|
||||
messagePrefix: '\x18BitCore Signed Message:\n',
|
||||
bech32: 'bitcore',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4
|
||||
},
|
||||
pubKeyHash: 0x03,
|
||||
scriptHash: 0x7D,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x37,
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x37,
|
||||
wif: 0xb0
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.syscoin.p2wpkh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.syscoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "syscoin",
|
||||
messagePrefix: '\x18Syscoin Signed Message:\n',
|
||||
bech32: 'sys',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.viacoin.p2wpkh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x47,
|
||||
scriptHash: 0x21,
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.viacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "viacoin",
|
||||
messagePrefix: '\x18Viacoin Signed Message:\n',
|
||||
bech32: 'viacoin',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x47,
|
||||
scriptHash: 0x21,
|
||||
wif: 0xc7
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.dogecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "dogecointestnet",
|
||||
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
||||
bech32: 'dogecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x71,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xf1
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.litecointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "litecointestnet",
|
||||
messagePrefix: '\x18Litecoin Signed Message:\n',
|
||||
bech32: 'litecointestnet',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x24,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcoin",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'grs',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x24,
|
||||
scriptHash: 0x05,
|
||||
wif: 0x80,
|
||||
};
|
||||
|
||||
bitcoinjs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "groestlcointestnet",
|
||||
messagePrefix: '\x19GroestlCoin Signed Message:\n',
|
||||
bech32: 'tgrs',
|
||||
bip32: {
|
||||
public: 0x044a5262,
|
||||
private: 0x044a4e28
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -26,13 +26,13 @@ var sjcl = {
|
||||
|
||||
/** @namespace Key exchange functions. Right now only SRP is implemented. */
|
||||
keyexchange: {},
|
||||
|
||||
|
||||
/** @namespace Block cipher modes of operation. */
|
||||
mode: {},
|
||||
|
||||
/** @namespace Miscellaneous. HMAC and PBKDF2. */
|
||||
misc: {},
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Bit array encoders and decoders.
|
||||
*
|
||||
@@ -43,7 +43,7 @@ var sjcl = {
|
||||
* the method names are "fromBits" and "toBits".
|
||||
*/
|
||||
codec: {},
|
||||
|
||||
|
||||
/** @namespace Exceptions. */
|
||||
exception: {
|
||||
/** @constructor Ciphertext is corrupt. */
|
||||
@@ -51,13 +51,13 @@ var sjcl = {
|
||||
this.toString = function() { return "CORRUPT: "+this.message; };
|
||||
this.message = message;
|
||||
},
|
||||
|
||||
|
||||
/** @constructor Invalid parameter. */
|
||||
invalid: function(message) {
|
||||
this.toString = function() { return "INVALID: "+this.message; };
|
||||
this.message = message;
|
||||
},
|
||||
|
||||
|
||||
/** @constructor Bug or missing feature in SJCL. @constructor */
|
||||
bug: function(message) {
|
||||
this.toString = function() { return "BUG: "+this.message; };
|
||||
@@ -159,7 +159,7 @@ sjcl.bitArray = {
|
||||
if (a1.length === 0 || a2.length === 0) {
|
||||
return a1.concat(a2);
|
||||
}
|
||||
|
||||
|
||||
var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
|
||||
if (shift === 32) {
|
||||
return a1.concat(a2);
|
||||
@@ -245,7 +245,7 @@ sjcl.bitArray = {
|
||||
_shiftRight: function (a, shift, carry, out) {
|
||||
var i, last2=0, shift2;
|
||||
if (out === undefined) { out = []; }
|
||||
|
||||
|
||||
for (; shift >= 32; shift -= 32) {
|
||||
out.push(carry);
|
||||
carry = 0;
|
||||
@@ -253,7 +253,7 @@ sjcl.bitArray = {
|
||||
if (shift === 0) {
|
||||
return out.concat(a);
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<a.length; i++) {
|
||||
out.push(carry | a[i]>>>shift);
|
||||
carry = a[i] << (32-shift);
|
||||
@@ -263,7 +263,7 @@ sjcl.bitArray = {
|
||||
out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
|
||||
return out;
|
||||
},
|
||||
|
||||
|
||||
/** xor a block of 4 words together.
|
||||
* @private
|
||||
*/
|
||||
@@ -295,7 +295,7 @@ sjcl.bitArray = {
|
||||
* @author Mike Hamburg
|
||||
* @author Dan Boneh
|
||||
*/
|
||||
|
||||
|
||||
/** @namespace UTF-8 strings */
|
||||
sjcl.codec.utf8String = {
|
||||
/** Convert from a bitArray to a UTF-8 string. */
|
||||
@@ -310,7 +310,7 @@ sjcl.codec.utf8String = {
|
||||
}
|
||||
return decodeURIComponent(escape(out));
|
||||
},
|
||||
|
||||
|
||||
/** Convert from a UTF-8 string to a bitArray. */
|
||||
toBits: function (str) {
|
||||
str = unescape(encodeURIComponent(str));
|
||||
@@ -412,7 +412,7 @@ sjcl.hash.sha512.prototype = {
|
||||
* @constant
|
||||
*/
|
||||
blockSize: 1024,
|
||||
|
||||
|
||||
/**
|
||||
* Reset the hash state.
|
||||
* @return this
|
||||
@@ -423,7 +423,7 @@ sjcl.hash.sha512.prototype = {
|
||||
this._length = 0;
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Input several words to the hash.
|
||||
* @param {bitArray|String} data the data to hash.
|
||||
@@ -441,7 +441,7 @@ sjcl.hash.sha512.prototype = {
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Complete hashing and output the hash value.
|
||||
* @return {bitArray} The hash value, an array of 16 big-endian words.
|
||||
@@ -736,12 +736,12 @@ sjcl.misc.hmac = function (key, Hash) {
|
||||
if (key.length > bs) {
|
||||
key = Hash.hash(key);
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<bs; i++) {
|
||||
exKey[0][i] = key[i]^0x36363636;
|
||||
exKey[1][i] = key[i]^0x5C5C5C5C;
|
||||
}
|
||||
|
||||
|
||||
this._baseHash[0].update(exKey[0]);
|
||||
this._baseHash[1].update(exKey[1]);
|
||||
this._resultHash = new Hash(this._baseHash[0]);
|
||||
@@ -804,34 +804,34 @@ sjcl.misc.hmac.prototype.digest = function () {
|
||||
*/
|
||||
sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
|
||||
count = count || 1000;
|
||||
|
||||
|
||||
if (length < 0 || count < 0) {
|
||||
throw sjcl.exception.invalid("invalid params to pbkdf2");
|
||||
}
|
||||
|
||||
|
||||
if (typeof password === "string") {
|
||||
password = sjcl.codec.utf8String.toBits(password);
|
||||
}
|
||||
|
||||
|
||||
if (typeof salt === "string") {
|
||||
salt = sjcl.codec.utf8String.toBits(salt);
|
||||
}
|
||||
|
||||
|
||||
Prff = Prff || sjcl.misc.hmac;
|
||||
|
||||
|
||||
var prf = new Prff(password),
|
||||
u, ui, i, j, k, out = [], b = sjcl.bitArray;
|
||||
|
||||
for (k = 1; 32 * out.length < (length || 1); k++) {
|
||||
u = ui = prf.encrypt(b.concat(salt,[k]));
|
||||
|
||||
|
||||
for (i=1; i<count; i++) {
|
||||
ui = prf.encrypt(ui);
|
||||
for (j=0; j<ui.length; j++) {
|
||||
u[j] ^= ui[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out = out.concat(u);
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ sjcl.hash.sha256.prototype = {
|
||||
* @constant
|
||||
*/
|
||||
blockSize: 512,
|
||||
|
||||
|
||||
/**
|
||||
* Reset the hash state.
|
||||
* @return this
|
||||
@@ -901,7 +901,7 @@ sjcl.hash.sha256.prototype = {
|
||||
this._length = 0;
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Input several words to the hash.
|
||||
* @param {bitArray|String} data the data to hash.
|
||||
@@ -919,7 +919,7 @@ sjcl.hash.sha256.prototype = {
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Complete hashing and output the hash value.
|
||||
* @return {bitArray} The hash value, an array of 8 big-endian words.
|
||||
@@ -929,12 +929,12 @@ sjcl.hash.sha256.prototype = {
|
||||
|
||||
// Round out and push the buffer
|
||||
b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
|
||||
|
||||
|
||||
// Round out the buffer to a multiple of 16 words, less the 2 length words.
|
||||
for (i = b.length + 2; i & 15; i++) {
|
||||
b.push(0);
|
||||
}
|
||||
|
||||
|
||||
// append the length
|
||||
b.push(Math.floor(this._length / 0x100000000));
|
||||
b.push(this._length | 0);
|
||||
@@ -955,7 +955,7 @@ sjcl.hash.sha256.prototype = {
|
||||
/*
|
||||
_init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The SHA-256 hash key, to be precomputed.
|
||||
* @private
|
||||
@@ -990,7 +990,7 @@ sjcl.hash.sha256.prototype = {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (i<8) {
|
||||
this._init[i] = frac(Math.pow(prime, 1/2));
|
||||
}
|
||||
@@ -998,13 +998,13 @@ sjcl.hash.sha256.prototype = {
|
||||
i++;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Perform one cycle of SHA-256.
|
||||
* @param {bitArray} words one block of words.
|
||||
* @private
|
||||
*/
|
||||
_block:function (words) {
|
||||
_block:function (words) {
|
||||
var i, tmp, a, b,
|
||||
w = words.slice(0),
|
||||
h = this._h,
|
||||
@@ -1032,13 +1032,13 @@ sjcl.hash.sha256.prototype = {
|
||||
} else {
|
||||
a = w[(i+1 ) & 15];
|
||||
b = w[(i+14) & 15];
|
||||
tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
|
||||
tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
|
||||
(b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
|
||||
w[i&15] + w[(i+9) & 15]) | 0;
|
||||
}
|
||||
|
||||
|
||||
tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
|
||||
|
||||
|
||||
// shift register
|
||||
h7 = h6; h6 = h5; h5 = h4;
|
||||
h4 = h3 + tmp | 0;
|
||||
|
||||
42516
src/js/stellar-util.js
Normal file
42516
src/js/stellar-util.js
Normal file
File diff suppressed because one or more lines are too long
@@ -73,16 +73,23 @@ else if (browser == "chrome") {
|
||||
|
||||
// Helper functions
|
||||
|
||||
function testNetwork(done, params) {
|
||||
function testNetwork(done, params, comparePub = false) {
|
||||
var phrase = params.phrase || 'abandon abandon ability';
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys(phrase);
|
||||
selectNetwork(params.selectText);
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe(params.firstAddress);
|
||||
done();
|
||||
});
|
||||
if (!comparePub) {
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe(params.firstAddress);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
getFirstPublicKey(function(pubkey) {
|
||||
expect(pubkey).toBe(params.firstPubKey);
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,6 +105,10 @@ function getFirstAddress(handler) {
|
||||
getFirstRowValue(handler, ".address");
|
||||
}
|
||||
|
||||
function getFirstPublicKey(handler) {
|
||||
getFirstRowValue(handler, ".pubkey");
|
||||
}
|
||||
|
||||
function getFirstPath(handler) {
|
||||
getFirstRowValue(handler, ".index");
|
||||
}
|
||||
@@ -408,6 +419,13 @@ it('Allows selection of litecoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of litecoin testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "LTCt - Litecoin Testnet",
|
||||
firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiyg2nJKi",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of ripple', function(done) {
|
||||
var params = {
|
||||
selectText: "XRP - Ripple",
|
||||
@@ -416,6 +434,14 @@ it('Allows selection of ripple', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of casinocoin', function(done) {
|
||||
var params = {
|
||||
selectText: "CSC - CasinoCoin",
|
||||
firstAddress: "c3P5EUb27Pzk9dcGt4s7zQDQj4sC6Y81mT",
|
||||
phrase: "ill clump only blind unit burden thing track silver cloth review awake useful craft whale all satisfy else trophy sunset walk vanish hope valve",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of dogecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "DOGE - Dogecoin",
|
||||
@@ -423,6 +449,13 @@ it('Allows selection of dogecoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of dogecoin testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "DOGEt - Dogecoin Testnet",
|
||||
firstAddress: "niHnSJKHdwDyDxRMLBJrtNqpvHEsAFWe6B",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of denarius', function(done) {
|
||||
var params = {
|
||||
selectText: "DNR - Denarius",
|
||||
@@ -474,11 +507,18 @@ it('Allows selection of clam', function(done) {
|
||||
});
|
||||
it('Allows selection of crown', function(done) {
|
||||
var params = {
|
||||
selectText: "CRW - Crown",
|
||||
selectText: "CRW - Crown (Legacy)",
|
||||
firstAddress: "18pWSwSUAQdiwMHUfFZB1fM2xue9X1FqE5",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of crown', function(done) {
|
||||
var params = {
|
||||
selectText: "CRW - Crown",
|
||||
firstAddress: "CRWKnVmVhvH1KWTYe6sq8xV4dFGcFpBEEkPQ",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of dash', function(done) {
|
||||
var params = {
|
||||
selectText: "DASH - Dash",
|
||||
@@ -521,6 +561,20 @@ it('Allows selection of onixcoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of lkrcoin', function(done) {
|
||||
var params = {
|
||||
selectText: "LKR - Lkrcoin",
|
||||
firstAddress: "LfbT296e7AEEnn4bYDbL535Nd8P9g98CdJ",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of bolivarcoin', function(done) {
|
||||
var params = {
|
||||
selectText: "BOLI - Bolivarcoin",
|
||||
firstAddress: "bbKzCAUR7hZ3nqfffy7VgrSz8LmAP3S5mK",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of peercoin', function(done) {
|
||||
var params = {
|
||||
selectText: "PPC - Peercoin",
|
||||
@@ -557,6 +611,15 @@ it('Allows selection of bitcoin cash', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
|
||||
it('Allows selection of simpleledger(SLP)', function(done) {
|
||||
var params = {
|
||||
selectText: "SLP - Simple Ledger Protocol",
|
||||
firstAddress: "simpleledger:qrtffz6ajfsn74gpur7y3epjquz42pvww5acewqmre",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
|
||||
it('Allows selection of myriadcoin', function(done) {
|
||||
var params = {
|
||||
selectText: "XMY - Myriadcoin",
|
||||
@@ -585,6 +648,20 @@ it('Allows selection of maza', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of FIX', function(done) {
|
||||
var params = {
|
||||
selectText: "FIX - FIX",
|
||||
firstAddress: "FS5MEU8fs5dUvsaSCSusV8RQtC8j2h3JEh",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of FIX testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "FIX - FIX Testnet",
|
||||
firstAddress: "XpnU1HHdNG5YxvG9Rez4wjmidchxqnZaNa",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of fujicoin', function(done) {
|
||||
var params = {
|
||||
selectText: "FJC - Fujicoin",
|
||||
@@ -655,6 +732,13 @@ it('Allows selection of Asiacoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Aryacoin', function(done) {
|
||||
var params = {
|
||||
selectText: "ARYA - Aryacoin",
|
||||
firstAddress: "Abr6gX25KaU9BpwD34UfsL3A4n89NvYYSf",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Auroracoin', function(done) {
|
||||
var params = {
|
||||
selectText: "AUR - Auroracoin",
|
||||
@@ -697,6 +781,13 @@ it('Allows selection of Bitcoin Private', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Bitcoin SV', function(done) {
|
||||
var params = {
|
||||
selectText: "BSV - BitcoinSV",
|
||||
firstAddress: "1N4mgtE5yxifch9jWs7Sds6oVqxdy2t576",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Bitcoinz', function(done) {
|
||||
var params = {
|
||||
selectText: "BTCZ - Bitcoinz",
|
||||
@@ -760,6 +851,13 @@ it('Allows selection of Compcoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of CPUchain', function(done) {
|
||||
var params = {
|
||||
selectText: "CPU - CPUchain",
|
||||
firstAddress: "CWSpLpW7jS4mBHJnkz3mmL5s3yQMg93zK8",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Crave', function(done) {
|
||||
var params = {
|
||||
selectText: "CRAVE - Crave",
|
||||
@@ -823,6 +921,13 @@ it('Allows selection of Einsteinium', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of EOSIO', function(done) {
|
||||
var params = {
|
||||
selectText: "EOS - EOSIO",
|
||||
firstPubKey: "EOS692VJTBK3Rmw93onNnpnZ8ZtmE9PdxjDStArvbyzoe11QUTNoy",
|
||||
};
|
||||
testNetwork(done, params, true);
|
||||
});
|
||||
it('Allows selection of Europecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "ERC - Europecoin",
|
||||
@@ -984,6 +1089,13 @@ it('Allows selection of Navcoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Nebulas', function(done) {
|
||||
var params = {
|
||||
selectText: "NAS - Nebulas",
|
||||
firstAddress: "n1PbK61DGBfDoDusLw621G6sVSMfLLHdfnm",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Neoscoin', function(done) {
|
||||
var params = {
|
||||
selectText: "NEOS - Neoscoin",
|
||||
@@ -991,6 +1103,13 @@ it('Allows selection of Neoscoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Nix', function(done) {
|
||||
var params = {
|
||||
selectText: "NIX - NIX Platform",
|
||||
firstAddress: "GgcNW2SQQXB4LWHRQTHKkQF3GzXNSLqS8u",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Neurocoin', function(done) {
|
||||
var params = {
|
||||
selectText: "NRO - Neurocoin",
|
||||
@@ -1033,6 +1152,13 @@ it('Allows selection of Omnicore', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of DeepOnion', function(done) {
|
||||
var params = {
|
||||
selectText: "ONION - DeepOnion",
|
||||
firstAddress: "DYREY7XCFXVqJ3x5UuN43k2JwD2s1kif48",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Pesobit', function(done) {
|
||||
var params = {
|
||||
selectText: "PSB - Pesobit",
|
||||
@@ -1068,6 +1194,20 @@ it('Allows selection of Putincoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Rapids', function(done) {
|
||||
var params = {
|
||||
selectText: "RPD - Rapids",
|
||||
firstAddress: "Ri8XxUdZaXS5LqxmFJcFEjFinkaMbmhSUp",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Ravencoin', function(done) {
|
||||
var params = {
|
||||
selectText: "RVN - Ravencoin",
|
||||
firstAddress: "RBuDoVNnzvFsEcX8XKPm8ic4mgiCzjUCNk",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Reddcoin', function(done) {
|
||||
var params = {
|
||||
selectText: "RDD - Reddcoin",
|
||||
@@ -1152,6 +1292,20 @@ it('Allows selection of Toa', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of TWINS', function(done) {
|
||||
var params = {
|
||||
selectText: "TWINS - TWINS",
|
||||
firstAddress: "WPpJnfLLubNmF7HLNxg8d8zH5haxn4wri8",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of TWINS testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "TWINS - TWINS Testnet",
|
||||
firstAddress: "XpnU1HHdNG5YxvG9Rez4wjmidchxqnZaNa",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Ultimatesecurecash', function(done) {
|
||||
var params = {
|
||||
selectText: "USC - Ultimatesecurecash",
|
||||
@@ -1201,6 +1355,13 @@ it('Allows selection of Vpncoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of VeChain', function(done) {
|
||||
var params = {
|
||||
selectText: "VET - VeChain",
|
||||
firstAddress: "0xdba55B1B6070f3a733D5eDFf35F0da4A00E455F2",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Whitecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "XWC - Whitecoin",
|
||||
@@ -1236,9 +1397,9 @@ it('Allows selection of Zclassic', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Zencash', function(done) {
|
||||
it('Allows selection of Horizen', function(done) {
|
||||
var params = {
|
||||
selectText: "ZEN - Zencash",
|
||||
selectText: "ZEN - Horizen",
|
||||
firstAddress: "znWh9XASyW2dZq5tck84wFjiwuqVysi7q3p",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
@@ -1271,6 +1432,14 @@ it('Allows selection of MIX', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Monkey Project', function(done) {
|
||||
var params = {
|
||||
selectText: "MONK - Monkey Project",
|
||||
firstAddress: "MnLrcnnUzKnf7TzufjRe5DLZqQJz18oYyu",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
|
||||
it('Allows selection of Musicoin', function(done) {
|
||||
var params = {
|
||||
selectText: "MUSIC - Musicoin",
|
||||
@@ -1301,11 +1470,18 @@ it('Allows selection of Callisto', function(done) {
|
||||
});
|
||||
it('Allows selection of HUSH', function(done) {
|
||||
var params = {
|
||||
selectText: "HUSH - Hush",
|
||||
selectText: "HUSH - Hush (Legacy)",
|
||||
firstAddress: "t1g6rLXUnJaiJuu4q4zmJjoa9Gk4fwKpiuA",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of HUSH3', function(done) {
|
||||
var params = {
|
||||
selectText: "HUSH - Hush3",
|
||||
firstAddress: "RXWSQhwvw5jHPGP8bjwJhWoRnMLBnuPDKD",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of ExchangeCoin', function(done) {
|
||||
var params = {
|
||||
selectText: "EXCC - ExchangeCoin",
|
||||
@@ -1341,6 +1517,118 @@ it('Allows selection of ProjectCoin', function(done) {
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Phore', function(done) {
|
||||
var params = {
|
||||
selectText: "PHR - Phore",
|
||||
firstAddress: "PJThxpoXAG6hqrmdeQQbVDX4TJtFTMMymC",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Safecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "SAFE - Safecoin",
|
||||
firstAddress: "RtxHpnhJz6RY8k9owP3ua5QWraunmewB1G",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Blocknode', function(done) {
|
||||
var params = {
|
||||
selectText: "BND - Blocknode",
|
||||
firstAddress: "BG8xZSAur2jYLG9VXt8dYfkKxxeR7w9bSe",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Blocknode Testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "tBND - Blocknode Testnet",
|
||||
firstAddress: "bSptsFyDktFSKpWveRywJsDoJA2TC6qfHv",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of LitecoinZ', function(done) {
|
||||
var params = {
|
||||
selectText: "LTZ - LitecoinZ",
|
||||
firstAddress: "L1VTXju7hLgKV4T7fGXS9sKsnm2gmtRCmyw",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of BlockStamp', function(done) {
|
||||
var params = {
|
||||
selectText: "BST - BlockStamp",
|
||||
firstAddress: "15gypKtim4cVTj137ApfryG17RkvSbPazZ",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of DEXON', function(done) {
|
||||
var params = {
|
||||
selectText: "DXN - DEXON",
|
||||
firstAddress: "0x136a58788033E028CCd740FbDec6734358DB56Ec",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Ellaism', function(done) {
|
||||
var params = {
|
||||
selectText: "ELLA - Ellaism",
|
||||
firstAddress: "0xa8B0BeA09eeBc41062308546a01d6E544277e2Ca",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Ethersocial Network', function(done) {
|
||||
var params = {
|
||||
selectText: "ESN - Ethersocial Network",
|
||||
firstAddress: "0x6EE99Be2A0C7F887a71e21C8608ACF0aa0D2b767",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Stellar', function(done) {
|
||||
var params = {
|
||||
selectText: "XLM - Stellar",
|
||||
firstAddress: "GCUK3NYYUXA2QGN6KU5RR36WAKN3Y5EANZV65XNAWN4XM4CHQ3G4DMO2",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Wagerr', function(done) {
|
||||
var params = {
|
||||
selectText: "WGR - Wagerr",
|
||||
firstAddress: "WYiVgQU39VcQxcnacoCiaZHZZLjDCJoS95",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Groestlcoin', function(done) {
|
||||
var params = {
|
||||
selectText: "GRS - Groestlcoin",
|
||||
firstAddress: "FZycsFvZ1eH1hbtyjBpAgJSukVw1bN6PBN",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Groestlcoin Testnet', function(done) {
|
||||
var params = {
|
||||
selectText: "GRS - Groestlcoin Testnet",
|
||||
firstAddress: "mucaU5iiDaJDb69BHLeDv8JFfGiygRPne9",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Elastos', function(done) {
|
||||
var params = {
|
||||
selectText: "ELA - Elastos",
|
||||
firstAddress: "EMccDcsn3SwPDcfeQMf3w7utqi8ioWYtkg",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Energyweb', function(done) {
|
||||
var params = {
|
||||
selectText: "EWT - EnergyWeb",
|
||||
firstAddress: "0x22171474844Fc7E8E99A3A69CCf1eDb5574FdD4c",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
it('Allows selection of Thought', function(done) {
|
||||
var params = {
|
||||
selectText: "THT - Thought",
|
||||
firstAddress: "4B1Bh9GibDarFQrhtYU8krpc7WSjgGfYvo",
|
||||
};
|
||||
testNetwork(done, params);
|
||||
});
|
||||
|
||||
// BIP39 seed is set from phrase
|
||||
it('Sets the bip39 seed from the prhase', function(done) {
|
||||
@@ -1921,6 +2209,7 @@ it('Ignores excess whitespace in the mnemonic', function(done) {
|
||||
|
||||
// Github Issue 23: Part 1: Use correct derivation path when changing tabs
|
||||
// https://github.com/iancoleman/bip39/issues/23
|
||||
// This test was failing for default timeout of 5000ms so changed it to +10s
|
||||
it('Uses the correct derivation path when changing tabs', function(done) {
|
||||
// 1) and 2) set the phrase
|
||||
driver.findElement(By.css('.phrase'))
|
||||
@@ -1945,7 +2234,7 @@ it('Uses the correct derivation path when changing tabs', function(done) {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, generateDelay + 10000);
|
||||
|
||||
// Github Issue 23 Part 2: Coin selection in derivation path
|
||||
// https://github.com/iancoleman/bip39/issues/23#issuecomment-238011920
|
||||
@@ -3803,6 +4092,27 @@ it('Shows litecoin BIP49 addresses', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
it('Shows Groestlcoin BIP49 addresses', function(done) {
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('abandon abandon ability');
|
||||
selectNetwork("GRS - Groestlcoin");
|
||||
driver.findElement(By.css('#bip49-tab a'))
|
||||
.click()
|
||||
// bip49 addresses are shown
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css('#bip49 .available'))
|
||||
.getAttribute("class")
|
||||
.then(function(classes) {
|
||||
expect(classes).not.toContain("hidden");
|
||||
// check first address
|
||||
getFirstAddress(function(address) {
|
||||
expect(address).toBe("3HXSCZwCypLyixMsF4Z1sN49noJtrm8gnX");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Can use root keys to generate segwit table rows', function(done) {
|
||||
// segwit uses ypub / zpub instead of xpub but the root key should still
|
||||
// be valid regardless of the encoding used to import that key.
|
||||
@@ -3822,4 +4132,57 @@ it('Can use root keys to generate segwit table rows', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
// Pull Request 271
|
||||
// Allow converting mnemonic back to raw entropy value
|
||||
it('Converts mnemonics into raw entropy', function(done) {
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys('abandon abandon about');
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css('.use-entropy'))
|
||||
.click();
|
||||
driver.findElement(By.css('.entropy'))
|
||||
.getAttribute("value")
|
||||
.then(function(entropy) {
|
||||
expect(entropy).toBe("00000000000000000000000000000001");
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.getAttribute("value")
|
||||
.then(function(phrase) {
|
||||
expect(phrase).toBe("abandon abandon about");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Pull Request 279
|
||||
// Added Split Phrase Card Output
|
||||
it('Shows split prase cards', function(done) {
|
||||
var originalPhrase = "ugly charge strong giant once anchor capable october thumb inject dwarf legal alley mixture shoot";
|
||||
var originalWords = originalPhrase.split(' ');
|
||||
driver.findElement(By.css('.phrase'))
|
||||
.sendKeys(originalPhrase);
|
||||
driver.sleep(generateDelay).then(function() {
|
||||
driver.findElement(By.css('.phraseSplit'))
|
||||
.getAttribute("value")
|
||||
.then(function(cardsStr) {
|
||||
var cards = cardsStr.split("\n");
|
||||
expect(cards.length).toBe(3);
|
||||
// test all 2-of-3 combos can be used to form full phrase
|
||||
var combos = [[0,1],[0,2],[1,2]];
|
||||
for (var i=0; i<combos.length; i++) {
|
||||
var combo = combos[i];
|
||||
var a = combo[0];
|
||||
var b = combo[1];
|
||||
var phrase = cards[a] + " " + cards[b];
|
||||
// check all original words are present
|
||||
for (var j=0; j<originalWords.length; j++) {
|
||||
var originalWord = originalWords[j];
|
||||
expect(phrase).toContain(originalWord);
|
||||
}
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user