mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-18 16:32:18 +00:00
@@ -14,6 +14,10 @@ module.exports.bchaddr = require('bchaddrjs')
|
|||||||
|
|
||||||
module.exports.bchaddrSlp = require('bchaddrjs-slp')
|
module.exports.bchaddrSlp = require('bchaddrjs-slp')
|
||||||
|
|
||||||
|
/* bech32 */
|
||||||
|
|
||||||
|
module.exports.bech32 = require('bech32')
|
||||||
|
|
||||||
/* biginteger */
|
/* biginteger */
|
||||||
|
|
||||||
module.exports.BigInteger = require('javascript-biginteger')
|
module.exports.BigInteger = require('javascript-biginteger')
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"base-x": "3.0.7",
|
"base-x": "3.0.7",
|
||||||
"bchaddrjs": "0.4.4",
|
"bchaddrjs": "0.4.4",
|
||||||
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
||||||
|
"bech32": "1.1.4",
|
||||||
"bip38": "2.0.2",
|
"bip38": "2.0.2",
|
||||||
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
||||||
"bip85": "0.0.3",
|
"bip85": "0.0.3",
|
||||||
|
|||||||
@@ -1101,6 +1101,7 @@
|
|||||||
<script src="js/ripple-util.js"></script>
|
<script src="js/ripple-util.js"></script>
|
||||||
<script src="js/jingtum-util.js"></script>
|
<script src="js/jingtum-util.js"></script>
|
||||||
<script src="js/casinocoin-util.js"></script>
|
<script src="js/casinocoin-util.js"></script>
|
||||||
|
<script src="js/cosmos-util.js"></script>
|
||||||
<script src="js/eos-util.js"></script>
|
<script src="js/eos-util.js"></script>
|
||||||
<script src="js/fio-util.js"></script>
|
<script src="js/fio-util.js"></script>
|
||||||
<script src="js/sjcl-bip39.js"></script>
|
<script src="js/sjcl-bip39.js"></script>
|
||||||
|
|||||||
13
src/js/cosmos-util.js
Normal file
13
src/js/cosmos-util.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
function CosmosBufferToPublic(pubBuf) {
|
||||||
|
const Buffer = libs.buffer.Buffer;
|
||||||
|
const AminoSecp256k1PubkeyPrefix = Buffer.from("EB5AE987", "hex");
|
||||||
|
const AminoSecp256k1PubkeyLength = Buffer.from("21", "hex");
|
||||||
|
pubBuf = Buffer.concat([AminoSecp256k1PubkeyPrefix, AminoSecp256k1PubkeyLength, pubBuf]);
|
||||||
|
return libs.bech32.encode("cosmospub", libs.bech32.toWords(pubBuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
function CosmosBufferToAddress(pubBuf) {
|
||||||
|
const sha256_ed = libs.createHash("sha256").update(pubBuf).digest();
|
||||||
|
const ripemd160_ed = libs.createHash("rmd160").update(sha256_ed).digest();
|
||||||
|
return libs.bech32.encode("cosmos", libs.bech32.toWords(ripemd160_ed));
|
||||||
|
}
|
||||||
@@ -1419,6 +1419,12 @@
|
|||||||
privkey = FIObufferToPrivate(keyPair.d.toBuffer(32));
|
privkey = FIObufferToPrivate(keyPair.d.toBuffer(32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (networks[DOM.network.val()].name == "ATOM - Cosmos Hub") {
|
||||||
|
address = CosmosBufferToAddress(keyPair.getPublicKeyBuffer());
|
||||||
|
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer());
|
||||||
|
privkey = keyPair.d.toBuffer().toString("base64");
|
||||||
|
}
|
||||||
|
|
||||||
//Groestlcoin Addresses are different
|
//Groestlcoin Addresses are different
|
||||||
if(isGRS()) {
|
if(isGRS()) {
|
||||||
|
|
||||||
@@ -2234,6 +2240,13 @@
|
|||||||
setHdCoin(357);
|
setHdCoin(357);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "ATOM - Cosmos Hub",
|
||||||
|
onSelect: function() {
|
||||||
|
network = libs.bitcoin.networks.bitcoin;
|
||||||
|
setHdCoin(118);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "AUR - Auroracoin",
|
name: "AUR - Auroracoin",
|
||||||
onSelect: function() {
|
onSelect: function() {
|
||||||
|
|||||||
@@ -917,6 +917,16 @@ it('Allows selection of Aryacoin', function(done) {
|
|||||||
};
|
};
|
||||||
testNetwork(done, params);
|
testNetwork(done, params);
|
||||||
});
|
});
|
||||||
|
it('Allows selection of Cosmos Hub', function(done) {
|
||||||
|
var params = {
|
||||||
|
selectText: "ATOM - Cosmos Hub",
|
||||||
|
phrase: "abandon abandon ability",
|
||||||
|
firstAddress: "cosmos17mkch9syem8gtf6wh7p38thdgav6dwezpkylny",
|
||||||
|
firstPubKey: "cosmospub1addwnpepq0sgn66ty4suk5vx3hsmxxqd5z3amegqwlu59funrzyz5u8r9758qhl84ys",
|
||||||
|
firstPrivKey: "zUnETPxmE2vkHzLHTAlO9wg8PL/GEEBc1I4yVwvSV8M=",
|
||||||
|
};
|
||||||
|
testNetwork(done, params);
|
||||||
|
});
|
||||||
it('Allows selection of Auroracoin', function(done) {
|
it('Allows selection of Auroracoin', function(done) {
|
||||||
var params = {
|
var params = {
|
||||||
selectText: "AUR - Auroracoin",
|
selectText: "AUR - Auroracoin",
|
||||||
|
|||||||
Reference in New Issue
Block a user