mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-07 03:12:14 +00:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f32b24e380 | ||
|
|
26767a2ce3 | ||
|
|
a748c4b5c6 | ||
|
|
eaf7892872 | ||
|
|
677d18f2e0 | ||
|
|
f3051a6a9f | ||
|
|
bf528f65f4 | ||
|
|
5699633538 | ||
|
|
d1d8699fc4 | ||
|
|
e284827677 | ||
|
|
115eb45083 | ||
|
|
0d78c2a120 | ||
|
|
7594405011 | ||
|
|
d359fe64b2 | ||
|
|
1bf76fe32d | ||
|
|
904e39748c | ||
|
|
46054e445e | ||
|
|
4958ea8009 | ||
|
|
0e1fd95302 | ||
|
|
a823e5266c | ||
|
|
b64fb35301 | ||
|
|
54600393af | ||
|
|
ff2940e81e | ||
|
|
f3101bd3f1 | ||
|
|
46a5338e42 | ||
|
|
c578337f0f | ||
|
|
90f7a5ec93 | ||
|
|
dd496c82c1 | ||
|
|
1dafc30db4 | ||
|
|
927450e169 | ||
|
|
a67554c649 | ||
|
|
0bc6361db4 | ||
|
|
a98d40c43d | ||
|
|
54a8e781b4 | ||
|
|
c1d6274224 | ||
|
|
c16661aeea | ||
|
|
e9491c7efd | ||
|
|
d07983bc1f | ||
|
|
3aa7677ace | ||
|
|
9e04576e2f | ||
|
|
8131a07115 | ||
|
|
181b5d61e3 | ||
|
|
4dfc681f71 | ||
|
|
dfb4fd1be5 |
25
changelog.md
25
changelog.md
@@ -1,3 +1,28 @@
|
||||
# 0.4.3
|
||||
|
||||
* Add FIO - Foundation for Interwallet Operability
|
||||
* Add Argoneum
|
||||
* Add CranePay
|
||||
* Add Jingtum network
|
||||
* Add MOAC
|
||||
* Update RSK network
|
||||
* Add HandShake
|
||||
* Add Sugarchain testnet
|
||||
* Fix wording "is a checksum" / "contains a checksum"
|
||||
* Fix bech32 prefix for monacoin
|
||||
|
||||
# 0.4.2
|
||||
|
||||
* Fix ethereum private key format
|
||||
|
||||
# 0.4.1
|
||||
|
||||
* Fix no loading on chrome with third-party cookies blocked
|
||||
* Add EtherCore
|
||||
* Add RSK network
|
||||
* Add DeepOnion segwit parameters
|
||||
* Fix ethereum xpub derivation
|
||||
|
||||
# 0.4.0
|
||||
|
||||
* Third party libraries deduplicated and minified
|
||||
|
||||
@@ -1,66 +1,72 @@
|
||||
/* base-x */
|
||||
|
||||
let basex = require('base-x')
|
||||
module.exports.basex = require('base-x')
|
||||
|
||||
/* bchaddrjs */
|
||||
|
||||
let bchaddr = require('bchaddrjs')
|
||||
module.exports.bchaddr = require('bchaddrjs')
|
||||
|
||||
/* bchaddrjs slp */
|
||||
|
||||
let bchaddrSlp = require('bchaddrjs-slp')
|
||||
module.exports.bchaddrSlp = require('bchaddrjs-slp')
|
||||
|
||||
/* biginteger */
|
||||
|
||||
let BigInteger = require('javascript-biginteger')
|
||||
module.exports.BigInteger = require('javascript-biginteger')
|
||||
|
||||
/* bitcoinjs-bip38 */
|
||||
|
||||
let bip38 = require('bip38')
|
||||
module.exports.bip38 = require('bip38')
|
||||
|
||||
/* bitcoinjs-lib */
|
||||
|
||||
let bitcoin = require('bitcoinjs-lib')
|
||||
module.exports.bitcoin = require('bitcoinjs-lib')
|
||||
|
||||
/* buffer */
|
||||
|
||||
let buffer = require('buffer');
|
||||
module.exports.buffer = require('buffer');
|
||||
|
||||
/* elastos */
|
||||
// See https://github.com/iancoleman/bip39/pull/368
|
||||
// and https://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript/tree/iancoleman-bip39
|
||||
|
||||
let elastosjs = require('elastos-wallet-js')
|
||||
module.exports.elastosjs = require('elastos-wallet-js')
|
||||
|
||||
/* ethereum-util */
|
||||
|
||||
let ethUtil = require('ethereumjs-util')
|
||||
module.exports.ethUtil = require('ethereumjs-util')
|
||||
|
||||
/* fast-levenshtein */
|
||||
|
||||
let levenshtein = require('fast-levenshtein')
|
||||
module.exports.levenshtein = require('fast-levenshtein')
|
||||
|
||||
/* groestlcoin */
|
||||
|
||||
let groestlcoinjs = require('groestlcoinjs-lib')
|
||||
module.exports.groestlcoinjs = require('groestlcoinjs-lib')
|
||||
|
||||
/* groestlcoin bip38 */
|
||||
|
||||
let groestlcoinjsBip38 = require('bip38grs')
|
||||
module.exports.groestlcoinjsBip38 = require('bip38grs')
|
||||
|
||||
/* kjua qr codes */
|
||||
|
||||
let kjua = require('kjua')
|
||||
module.exports.kjua = require('kjua')
|
||||
|
||||
/* nebulas */
|
||||
|
||||
let nebulas = require('nebulas')
|
||||
try {
|
||||
module.exports.nebulas = require('nebulas')
|
||||
}
|
||||
catch (e) {
|
||||
console.warn("Error loading nebulas library");
|
||||
console.warn(e);
|
||||
};
|
||||
|
||||
/* stellar-util */
|
||||
|
||||
let StellarBase = require('stellar-base');
|
||||
let edHd = require('ed25519-hd-key');
|
||||
let stellarUtil = {
|
||||
module.exports.stellarUtil = {
|
||||
getKeypair: function (path, seed) {
|
||||
const result = edHd.derivePath(path, seed);
|
||||
return StellarBase.Keypair.fromRawEd25519Seed(result.key);
|
||||
@@ -76,30 +82,30 @@ let stellarUtil = {
|
||||
|
||||
/* unorm */
|
||||
|
||||
let unorm = require('unorm')
|
||||
module.exports.unorm = require('unorm')
|
||||
|
||||
/* zxcvbn */
|
||||
|
||||
let zxcvbn = require('zxcvbn')
|
||||
module.exports.zxcvbn = require('zxcvbn')
|
||||
|
||||
/* exports */
|
||||
/* handshake */
|
||||
module.exports.handshake = require('handshake-util')
|
||||
|
||||
module.exports = {
|
||||
basex,
|
||||
bchaddr,
|
||||
bchaddrSlp,
|
||||
buffer,
|
||||
BigInteger,
|
||||
bip38,
|
||||
bitcoin,
|
||||
elastosjs,
|
||||
ethUtil,
|
||||
groestlcoinjs,
|
||||
groestlcoinjsBip38,
|
||||
kjua,
|
||||
levenshtein,
|
||||
nebulas,
|
||||
stellarUtil,
|
||||
unorm,
|
||||
zxcvbn
|
||||
/* bs58 */
|
||||
try {
|
||||
module.exports.bs58 = require('bs58')
|
||||
}
|
||||
catch (e) {
|
||||
console.warn("Error loading bs58 library");
|
||||
console.warn(e);
|
||||
};
|
||||
|
||||
/* create-hash */
|
||||
try {
|
||||
module.exports.createHash = require('create-hash')
|
||||
}
|
||||
catch (e) {
|
||||
console.warn("Error loading create-hash library");
|
||||
console.warn(e);
|
||||
};
|
||||
|
||||
|
||||
4
libs/combined/package.json
Normal file → Executable file
4
libs/combined/package.json
Normal file → Executable file
@@ -11,13 +11,17 @@
|
||||
"bip38": "2.0.2",
|
||||
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
||||
"bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit",
|
||||
"bs58": "^4.0.1",
|
||||
"buffer": "5.4.3",
|
||||
"create-hash": "^1.2.0",
|
||||
"ed25519-hd-key": "^1.0.0",
|
||||
"elastos-wallet-js": "git://github.com/johnnynanjiang/Elastos.SDK.Keypair.Javascript.git#491dc51b64efaf0a8aae62028b68e2c8e38fde06",
|
||||
"ethereumjs-util": "6.0.0",
|
||||
"handshake-util": "1.2.0",
|
||||
"fast-levenshtein": "2.0.6",
|
||||
"groestlcoinjs-lib": "git://github.com/Groestlcoin/groestlcoinjs-lib.git#3.3.2",
|
||||
"javascript-biginteger": "0.9.2",
|
||||
"jsrsasign": "^8.0.15",
|
||||
"kjua": "0.6.0",
|
||||
"nebulas": "0.5.6",
|
||||
"stellar-base": "^0.10.0",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="container">
|
||||
|
||||
<h1 class="text-center">Mnemonic Code Converter</h1>
|
||||
<p class="version">v0.4.0</p>
|
||||
<p class="version">v0.4.3</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"></div>
|
||||
<div class="col-sm-10">
|
||||
<p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum).</p>
|
||||
<p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word contains a checksum).</p>
|
||||
<p>
|
||||
For more info see the
|
||||
<a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a>.
|
||||
@@ -963,8 +963,10 @@
|
||||
<script src="js/bitcoinjs-extensions.js"></script>
|
||||
<script src="js/segwit-parameters.js"></script>
|
||||
<script src="js/ripple-util.js"></script>
|
||||
<script src="js/jingtum-util.js"></script>
|
||||
<script src="js/casinocoin-util.js"></script>
|
||||
<script src="js/eos-util.js"></script>
|
||||
<script src="js/fio-util.js"></script>
|
||||
<script src="js/sjcl-bip39.js"></script>
|
||||
<script src="js/wordlist_english.js"></script>
|
||||
<script src="js/wordlist_japanese.js"></script>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -581,6 +581,17 @@ libs.bitcoin.networks.cannacoin = {
|
||||
wif: 0x9c,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.cranepay = {
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 28,
|
||||
scriptHash: 10,
|
||||
wif: 123,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.cryptoescudo = {
|
||||
messagePrefix: '\x18Cryptoescudo Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1175,6 +1186,31 @@ libs.bitcoin.networks.revolutionvr = {
|
||||
wif: 0xc6,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.rsk = {
|
||||
messagePrefix: '\x18RSK Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
// TODO defaulting to Bitcoin value, check this
|
||||
pubKeyHash: 0x00,
|
||||
// TODO defaulting to Bitcoin value, check this
|
||||
scriptHash: 0x05,
|
||||
// TODO defaulting to Bitcoin value, check this
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.rsktestnet = {
|
||||
messagePrefix: '\x18RSK Testnet Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x043587cf,
|
||||
private: 0x04358394
|
||||
},
|
||||
pubKeyHash: 0x6f,
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.rubycoin = {
|
||||
messagePrefix: '\x18Rubycoin Signed Message:\n',
|
||||
bip32: {
|
||||
@@ -1739,6 +1775,28 @@ libs.bitcoin.networks.elastos = {
|
||||
wif: 0xef // TODO set this correctly, same as BTC for now
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchain = {
|
||||
messagePrefix: '\x18Sugarchain Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x0488B21E,
|
||||
private: 0x0488ADE4,
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x7d,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchaintestnet = {
|
||||
messagePrefix: '\x18Sugarchain Signed Message:\n',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc,
|
||||
},
|
||||
pubKeyHash: 0x42,
|
||||
scriptHash: 0x80,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
// https://github.com/libs.bitcoinjs-lib/blob/3f6f5ef97a1ee1b8337865209282c0095e22b2e7/src/networks.js
|
||||
libs.bitcoin.networks.regtest = {
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
@@ -1751,3 +1809,14 @@ libs.bitcoin.networks.regtest = {
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef,
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.argoneum = {
|
||||
messagePrefix: 'unused',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x32,
|
||||
scriptHash: 0x61,
|
||||
wif: 0xbf
|
||||
};
|
||||
|
||||
19
src/js/fio-util.js
Normal file
19
src/js/fio-util.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function FIObufferToPublic(pubBuf) {
|
||||
const Buffer = libs.buffer.Buffer;
|
||||
const FIO_PUBLIC_PREFIX = "FIO";
|
||||
|
||||
let checksum = libs.createHash("rmd160").update(pubBuf).digest("hex").slice(0, 8);
|
||||
pubBuf = Buffer.concat([pubBuf, Buffer.from(checksum, "hex")]);
|
||||
return FIO_PUBLIC_PREFIX.concat(libs.bs58.encode(pubBuf));
|
||||
}
|
||||
|
||||
function FIObufferToPrivate(privBuf) {
|
||||
const Buffer = libs.buffer.Buffer;
|
||||
const FIO_PRIVATE_PREFIX = "80";
|
||||
|
||||
privBuf = Buffer.concat([Buffer.from(FIO_PRIVATE_PREFIX, "hex"), privBuf]);
|
||||
let tmp = libs.createHash("sha256").update(privBuf).digest();
|
||||
let checksum = libs.createHash("sha256").update(tmp).digest("hex").slice(0, 8);
|
||||
privBuf = Buffer.concat([privBuf, Buffer.from(checksum, "hex")]);
|
||||
return libs.bs58.encode(privBuf);
|
||||
}
|
||||
182
src/js/index.js
182
src/js/index.js
@@ -1128,14 +1128,50 @@
|
||||
}
|
||||
// Ethereum values are different
|
||||
if (networkIsEthereum()) {
|
||||
var privKeyBuffer = keyPair.d.toBuffer(32);
|
||||
privkey = privKeyBuffer.toString('hex');
|
||||
var addressBuffer = libs.ethUtil.privateToAddress(privKeyBuffer);
|
||||
var pubkeyBuffer = keyPair.getPublicKeyBuffer();
|
||||
var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer);
|
||||
var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey);
|
||||
var hexAddress = addressBuffer.toString('hex');
|
||||
var checksumAddress = libs.ethUtil.toChecksumAddress(hexAddress);
|
||||
address = libs.ethUtil.addHexPrefix(checksumAddress);
|
||||
privkey = libs.ethUtil.addHexPrefix(privkey);
|
||||
pubkey = libs.ethUtil.addHexPrefix(pubkey);
|
||||
if (hasPrivkey) {
|
||||
privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
// RSK values are different
|
||||
if (networkIsRsk()) {
|
||||
var pubkeyBuffer = keyPair.getPublicKeyBuffer();
|
||||
var ethPubkey = libs.ethUtil.importPublic(pubkeyBuffer);
|
||||
var addressBuffer = libs.ethUtil.publicToAddress(ethPubkey);
|
||||
var hexAddress = addressBuffer.toString('hex');
|
||||
// Use chainId based on selected network
|
||||
// Ref: https://developers.rsk.co/rsk/architecture/account-based/#chainid
|
||||
var chainId;
|
||||
var rskNetworkName = networks[DOM.network.val()].name;
|
||||
switch (rskNetworkName) {
|
||||
case "R-BTC - RSK":
|
||||
chainId = 30;
|
||||
break;
|
||||
case "tR-BTC - RSK Testnet":
|
||||
chainId = 31;
|
||||
break;
|
||||
default:
|
||||
chainId = null;
|
||||
}
|
||||
var checksumAddress = toChecksumAddressForRsk(hexAddress, chainId);
|
||||
address = libs.ethUtil.addHexPrefix(checksumAddress);
|
||||
pubkey = libs.ethUtil.addHexPrefix(pubkey);
|
||||
if (hasPrivkey) {
|
||||
privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
// Handshake values are different
|
||||
if (networks[DOM.network.val()].name == "HNS - Handshake") {
|
||||
var ring = libs.handshake.KeyRing.fromPublic(keyPair.getPublicKeyBuffer())
|
||||
address = ring.getAddress().toString();
|
||||
}
|
||||
|
||||
// Stellar is different
|
||||
@@ -1163,6 +1199,11 @@
|
||||
privkey = convertRipplePriv(privkey);
|
||||
address = convertRippleAdrr(address);
|
||||
}
|
||||
// Jingtum values are different
|
||||
if (networks[DOM.network.val()].name == "SWTC - Jingtum") {
|
||||
privkey = convertJingtumPriv(privkey);
|
||||
address = convertJingtumAdrr(address);
|
||||
}
|
||||
// CasinoCoin values are different
|
||||
if (networks[DOM.network.val()].name == "CSC - CasinoCoin") {
|
||||
privkey = convertCasinoCoinPriv(privkey);
|
||||
@@ -1229,6 +1270,12 @@
|
||||
privkey = eosUtil.bufferToPrivate(keyPair.d.toBuffer(32));
|
||||
}
|
||||
|
||||
if (networks[DOM.network.val()].name == "FIO - Foundation for Interwallet Operability") {
|
||||
address = ""
|
||||
pubkey = FIObufferToPublic(keyPair.getPublicKeyBuffer());
|
||||
privkey = FIObufferToPrivate(keyPair.d.toBuffer(32));
|
||||
}
|
||||
|
||||
//Groestlcoin Addresses are different
|
||||
if(isGRS()) {
|
||||
|
||||
@@ -1830,6 +1877,7 @@
|
||||
|| (name == "EWT - EnergyWeb")
|
||||
|| (name == "PIRL - Pirl")
|
||||
|| (name == "MIX - MIX")
|
||||
|| (name == "MOAC - MOAC")
|
||||
|| (name == "MUSIC - Musicoin")
|
||||
|| (name == "POA - Poa")
|
||||
|| (name == "EXP - Expanse")
|
||||
@@ -1838,6 +1886,13 @@
|
||||
|| (name == "ELLA - Ellaism")
|
||||
|| (name == "ESN - Ethersocial Network")
|
||||
|| (name == "VET - VeChain")
|
||||
|| (name == "ERE - EtherCore")
|
||||
}
|
||||
|
||||
function networkIsRsk() {
|
||||
var name = networks[DOM.network.val()].name;
|
||||
return (name == "R-BTC - RSK")
|
||||
|| (name == "tR-BTC - RSK Testnet");
|
||||
}
|
||||
|
||||
function networkHasSegwit() {
|
||||
@@ -2021,6 +2076,13 @@
|
||||
setHdCoin(161);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AGM - Argoneum",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.argoneum;
|
||||
setHdCoin(421);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ARYA - Aryacoin",
|
||||
onSelect: function() {
|
||||
@@ -2269,6 +2331,14 @@
|
||||
setHdCoin(186);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CRP - CranePay",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.cranepay;
|
||||
setHdCoin(2304);
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "CRW - Crown (Legacy)",
|
||||
onSelect: function() {
|
||||
@@ -2417,6 +2487,14 @@
|
||||
setHdCoin(194);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ERE - EtherCore",
|
||||
segwitAvailable: false,
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(466);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ESN - Ethersocial Network",
|
||||
segwitAvailable: false,
|
||||
@@ -2469,6 +2547,13 @@
|
||||
setHdCoin(40);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FIO - Foundation for Interwallet Operability",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(235);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "FIX - FIX",
|
||||
onSelect: function() {
|
||||
@@ -2553,6 +2638,12 @@
|
||||
setHdCoin(1);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HNS - Handshake",
|
||||
onSelect: function() {
|
||||
setHdCoin(5353);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "HNC - Helleniccoin",
|
||||
onSelect: function() {
|
||||
@@ -2727,6 +2818,14 @@
|
||||
setHdCoin(214);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MOAC - MOAC",
|
||||
segwitAvailable: false,
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(314);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MUSIC - Musicoin",
|
||||
segwitAvailable: false,
|
||||
@@ -2947,6 +3046,20 @@
|
||||
setHdCoin(175);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "R-BTC - RSK",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.rsk;
|
||||
setHdCoin(137);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tR-BTC - RSK Testnet",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.rsktestnet;
|
||||
setHdCoin(37310);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "RBY - Rubycoin",
|
||||
onSelect: function() {
|
||||
@@ -3052,6 +3165,27 @@
|
||||
setHdCoin(105);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SUGAR - Sugarchain",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.sugarchain;
|
||||
setHdCoin(408);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "TUGAR - Sugarchain Testnet",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.sugarchaintestnet;
|
||||
setHdCoin(408);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "SWTC - Jingtum",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(315);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "TSTRAT - Stratis Testnet",
|
||||
onSelect: function() {
|
||||
@@ -3303,6 +3437,46 @@
|
||||
}
|
||||
]
|
||||
|
||||
// RSK - RSK functions - begin
|
||||
function stripHexPrefix(address) {
|
||||
if (typeof address !== "string") {
|
||||
throw new Error("address parameter should be a string.");
|
||||
}
|
||||
|
||||
var hasPrefix = (address.substring(0, 2) === "0x" ||
|
||||
address.substring(0, 2) === "0X");
|
||||
|
||||
return hasPrefix ? address.slice(2) : address;
|
||||
};
|
||||
|
||||
function toChecksumAddressForRsk(address, chainId = null) {
|
||||
if (typeof address !== "string") {
|
||||
throw new Error("address parameter should be a string.");
|
||||
}
|
||||
|
||||
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
|
||||
throw new Error("Given address is not a valid RSK address: " + address);
|
||||
}
|
||||
|
||||
var stripAddress = stripHexPrefix(address).toLowerCase();
|
||||
var prefix = chainId != null ? chainId.toString() + "0x" : "";
|
||||
var keccakHash = libs.ethUtil.keccak256(prefix + stripAddress)
|
||||
.toString("hex")
|
||||
.replace(/^0x/i, "");
|
||||
var checksumAddress = "0x";
|
||||
|
||||
for (var i = 0; i < stripAddress.length; i++) {
|
||||
checksumAddress +=
|
||||
parseInt(keccakHash[i], 16) >= 8 ?
|
||||
stripAddress[i].toUpperCase() :
|
||||
stripAddress[i];
|
||||
}
|
||||
|
||||
return checksumAddress;
|
||||
}
|
||||
|
||||
// RSK - RSK functions - end
|
||||
|
||||
// ELA - Elastos functions - begin
|
||||
function displayBip44InfoForELA() {
|
||||
if (!isELA()) {
|
||||
|
||||
10
src/js/jingtum-util.js
Normal file
10
src/js/jingtum-util.js
Normal file
@@ -0,0 +1,10 @@
|
||||
function convertJingtumAdrr(address) {
|
||||
return libs.basex('jpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65rkm8oFqi1tuvAxyz').encode(
|
||||
libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(address)
|
||||
)
|
||||
}
|
||||
|
||||
function convertJingtumPriv(priv) {
|
||||
return libs.basex('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz').decode(priv).toString("hex").slice(2,66)
|
||||
}
|
||||
|
||||
@@ -163,6 +163,36 @@ libs.bitcoin.networks.regtest.p2wshInP2sh = {
|
||||
scriptHash: 0xc4,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.cranepay.p2wpkhInP2sh = {
|
||||
baseNetwork: "cranepay",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'cp',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 28,
|
||||
scriptHash: 10,
|
||||
wif: 123
|
||||
};
|
||||
|
||||
// bech32
|
||||
libs.bitcoin.networks.cranepay.p2wpkh = {
|
||||
baseNetwork: "cranepay",
|
||||
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
||||
bech32: 'cp',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 28,
|
||||
scriptHash: 10,
|
||||
wif: 123
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
libs.bitcoin.networks.litecoin.p2wpkh = {
|
||||
baseNetwork: "litecoin",
|
||||
@@ -452,7 +482,7 @@ libs.bitcoin.networks.bitcore.p2wpkhInP2sh = {
|
||||
libs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bech32: 'mona',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
@@ -465,7 +495,7 @@ libs.bitcoin.networks.monacoin.p2wpkh = {
|
||||
libs.bitcoin.networks.monacoin.p2wpkhInP2sh = {
|
||||
baseNetwork: "monacoin",
|
||||
messagePrefix: '\x18Monacoin Signed Message:\n',
|
||||
bech32: 'monacoin',
|
||||
bech32: 'mona',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
@@ -657,4 +687,82 @@ libs.bitcoin.networks.groestlcointestnet.p2wpkhInP2sh = {
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.deeponion.p2wpkh = {
|
||||
baseNetwork: "deeponion",
|
||||
messagePrefix: '\x18DeepOnion Signed Message:\n',
|
||||
bech32: 'dpn',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x1f,
|
||||
scriptHash: 0x4e,
|
||||
wif: 0x9f
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.deeponion.p2wpkhInP2sh = {
|
||||
baseNetwork: "deeponion",
|
||||
messagePrefix: '\x18DeepOnion Signed Message:\n',
|
||||
bech32: 'dpn',
|
||||
bip32: {
|
||||
public: 0x0488b21e,
|
||||
private: 0x0488ade4
|
||||
},
|
||||
pubKeyHash: 0x1f,
|
||||
scriptHash: 0x4e,
|
||||
wif: 0x9f
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchain.p2wpkh = {
|
||||
baseNetwork: "sugarchain",
|
||||
messagePrefix: '\x1DSugarchain Signed Message:\n',
|
||||
bech32: 'sugar',
|
||||
bip32: {
|
||||
public: 0x04b24746,
|
||||
private: 0x04b2430c
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x7d,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchain.p2wpkhInP2sh = {
|
||||
baseNetwork: "sugarchain",
|
||||
messagePrefix: '\x1DSugarchain Signed Message:\n',
|
||||
bech32: 'sugar',
|
||||
bip32: {
|
||||
public: 0x049d7cb2,
|
||||
private: 0x049d7878
|
||||
},
|
||||
pubKeyHash: 0x3f,
|
||||
scriptHash: 0x7d,
|
||||
wif: 0x80
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchaintestnet.p2wpkh = {
|
||||
baseNetwork: "sugarchaintestnet",
|
||||
messagePrefix: '\x18Sugarchain Signed Message:\n',
|
||||
bech32: 'tugar',
|
||||
bip32: {
|
||||
public: 0x045f1cf6,
|
||||
private: 0x045f18bc
|
||||
},
|
||||
pubKeyHash: 0x42,
|
||||
scriptHash: 0x80,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
libs.bitcoin.networks.sugarchaintestnet.p2wpkhInP2sh = {
|
||||
baseNetwork: "sugarchaintestnet",
|
||||
messagePrefix: '\x18Sugarchain Signed Message:\n',
|
||||
bech32: 'tugar',
|
||||
bip32: {
|
||||
public: 0x044a5262,
|
||||
private: 0x044a4e28
|
||||
},
|
||||
pubKeyHash: 0x42,
|
||||
scriptHash: 0x80,
|
||||
wif: 0xef
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user