mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-18 16:32:18 +00:00
Add Starname (IOV) support
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
function CosmosBufferToPublic(pubBuf) {
|
function CosmosBufferToPublic(pubBuf, hrp = "cosmos") {
|
||||||
const Buffer = libs.buffer.Buffer;
|
const Buffer = libs.buffer.Buffer;
|
||||||
const AminoSecp256k1PubkeyPrefix = Buffer.from("EB5AE987", "hex");
|
const AminoSecp256k1PubkeyPrefix = Buffer.from("EB5AE987", "hex");
|
||||||
const AminoSecp256k1PubkeyLength = Buffer.from("21", "hex");
|
const AminoSecp256k1PubkeyLength = Buffer.from("21", "hex");
|
||||||
pubBuf = Buffer.concat([AminoSecp256k1PubkeyPrefix, AminoSecp256k1PubkeyLength, pubBuf]);
|
pubBuf = Buffer.concat([AminoSecp256k1PubkeyPrefix, AminoSecp256k1PubkeyLength, pubBuf]);
|
||||||
return libs.bech32.encode("cosmospub", libs.bech32.toWords(pubBuf));
|
return libs.bech32.encode(`${hrp}pub`, libs.bech32.toWords(pubBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
function CosmosBufferToAddress(pubBuf) {
|
function CosmosBufferToAddress(pubBuf, hrp = "cosmos") {
|
||||||
const sha256_ed = libs.createHash("sha256").update(pubBuf).digest();
|
const sha256_ed = libs.createHash("sha256").update(pubBuf).digest();
|
||||||
const ripemd160_ed = libs.createHash("rmd160").update(sha256_ed).digest();
|
const ripemd160_ed = libs.createHash("rmd160").update(sha256_ed).digest();
|
||||||
return libs.bech32.encode("cosmos", libs.bech32.toWords(ripemd160_ed));
|
return libs.bech32.encode(hrp, libs.bech32.toWords(ripemd160_ed));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1425,6 +1425,13 @@
|
|||||||
privkey = keyPair.d.toBuffer().toString("base64");
|
privkey = keyPair.d.toBuffer().toString("base64");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (networks[DOM.network.val()].name == "IOV - Starname") {
|
||||||
|
const hrp = "star";
|
||||||
|
address = CosmosBufferToAddress(keyPair.getPublicKeyBuffer(), hrp);
|
||||||
|
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer(), hrp);
|
||||||
|
privkey = keyPair.d.toBuffer().toString("base64");
|
||||||
|
}
|
||||||
|
|
||||||
//Groestlcoin Addresses are different
|
//Groestlcoin Addresses are different
|
||||||
if(isGRS()) {
|
if(isGRS()) {
|
||||||
|
|
||||||
@@ -2850,6 +2857,13 @@
|
|||||||
setHdCoin(66);
|
setHdCoin(66);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "IOV - Starname",
|
||||||
|
onSelect: function() {
|
||||||
|
network = libs.bitcoin.networks.bitcoin;
|
||||||
|
setHdCoin(234);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "IXC - Ixcoin",
|
name: "IXC - Ixcoin",
|
||||||
onSelect: function() {
|
onSelect: function() {
|
||||||
|
|||||||
@@ -1355,6 +1355,16 @@ it('Allows selection of Iop', function(done) {
|
|||||||
};
|
};
|
||||||
testNetwork(done, params);
|
testNetwork(done, params);
|
||||||
});
|
});
|
||||||
|
it('Allows selection of Starname', function(done) {
|
||||||
|
var params = {
|
||||||
|
selectText: "IOV - Starname",
|
||||||
|
phrase: "abandon abandon ability",
|
||||||
|
firstAddress: "star1xgfvgq40r7ff8ylw9l95dw56xnr0pvtjnlp7h4",
|
||||||
|
firstPubKey: "starpub1addwnpepqg9x5cft48hcgx25vyzeyygntl7pt763datr6v50hrecafyane54xlqdxkd",
|
||||||
|
firstPrivKey: "bGI4BNRvMYT1lbCOoH000HvNFPkyXms9n3Xp1X/7E80=",
|
||||||
|
};
|
||||||
|
testNetwork(done, params);
|
||||||
|
});
|
||||||
it('Allows selection of Ixcoin', function(done) {
|
it('Allows selection of Ixcoin', function(done) {
|
||||||
var params = {
|
var params = {
|
||||||
selectText: "IXC - Ixcoin",
|
selectText: "IXC - Ixcoin",
|
||||||
|
|||||||
Reference in New Issue
Block a user