mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-05 18:43:47 +00:00
Merge pull request #480 from xwcdev/master
Change xwc to xwcc according to slip-0044 and add xwc
This commit is contained in:
@@ -1104,6 +1104,7 @@
|
|||||||
<script src="js/cosmos-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/xwc-util.js"></script>
|
||||||
<script src="js/sjcl-bip39.js"></script>
|
<script src="js/sjcl-bip39.js"></script>
|
||||||
<script src="js/wordlist_english.js"></script>
|
<script src="js/wordlist_english.js"></script>
|
||||||
<script src="js/wordlist_japanese.js"></script>
|
<script src="js/wordlist_japanese.js"></script>
|
||||||
|
|||||||
@@ -1425,6 +1425,12 @@
|
|||||||
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer(), hrp);
|
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer(), hrp);
|
||||||
privkey = keyPair.d.toBuffer().toString("base64");
|
privkey = keyPair.d.toBuffer().toString("base64");
|
||||||
}
|
}
|
||||||
|
if (networks[DOM.network.val()].name == "XWC - Whitecoin"){
|
||||||
|
address = XWCbufferToAddress(keyPair.getPublicKeyBuffer());
|
||||||
|
pubkey = XWCbufferToPublic(keyPair.getPublicKeyBuffer());
|
||||||
|
privkey = XWCbufferToPrivate(keyPair.d.toBuffer(32));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (networks[DOM.network.val()].name == "LUNA - Terra") {
|
if (networks[DOM.network.val()].name == "LUNA - Terra") {
|
||||||
const hrp = "terra";
|
const hrp = "terra";
|
||||||
@@ -3597,7 +3603,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "XWC - Whitecoin",
|
name: "XWCC - Whitecoin Classic",
|
||||||
onSelect: function() {
|
onSelect: function() {
|
||||||
network = libs.bitcoin.networks.whitecoin;
|
network = libs.bitcoin.networks.whitecoin;
|
||||||
setHdCoin(155);
|
setHdCoin(155);
|
||||||
@@ -3638,6 +3644,13 @@
|
|||||||
setHdCoin(121);
|
setHdCoin(121);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "XWC - Whitecoin",
|
||||||
|
onSelect: function() {
|
||||||
|
network = libs.bitcoin.networks.bitcoin;
|
||||||
|
setHdCoin(559);
|
||||||
|
},
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
var clients = [
|
var clients = [
|
||||||
|
|||||||
28
src/js/xwc-util.js
Normal file
28
src/js/xwc-util.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
function XWCbufferToAddress(pubBuf){
|
||||||
|
const Buffer = libs.buffer.Buffer;
|
||||||
|
const XWC_ADDRESS_PREFIX = "XWC";
|
||||||
|
const XWC_NORMAL_ADDRESS_VERSION = "35"
|
||||||
|
let addrData = libs.createHash("rmd160").update( libs.createHash("sha512").update(pubBuf).digest()).digest();
|
||||||
|
let addrBuf = Buffer.concat([Buffer.from(XWC_NORMAL_ADDRESS_VERSION, "hex") ,addrData])
|
||||||
|
let checksum = libs.createHash("rmd160").update(addrBuf).digest("hex").slice(0, 8);
|
||||||
|
addrBuf = Buffer.concat([addrBuf, Buffer.from(checksum, "hex")]);
|
||||||
|
return XWC_ADDRESS_PREFIX.concat(libs.bs58.encode(addrBuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
function XWCbufferToPublic(pubBuf) {
|
||||||
|
const Buffer = libs.buffer.Buffer;
|
||||||
|
const XWC_PUBLIC_PREFIX = "XWC";
|
||||||
|
let checksum = libs.createHash("rmd160").update(pubBuf).digest("hex").slice(0, 8);
|
||||||
|
pubBuf = Buffer.concat([pubBuf, Buffer.from(checksum, "hex")]);
|
||||||
|
return XWC_PUBLIC_PREFIX.concat(libs.bs58.encode(pubBuf));
|
||||||
|
}
|
||||||
|
|
||||||
|
function XWCbufferToPrivate(privBuf) {
|
||||||
|
const Buffer = libs.buffer.Buffer;
|
||||||
|
const XWC_PRIVATE_PREFIX = "80";
|
||||||
|
privBuf = Buffer.concat([Buffer.from(XWC_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);
|
||||||
|
}
|
||||||
@@ -1895,9 +1895,9 @@ it('Allows selection of VeChain', function(done) {
|
|||||||
};
|
};
|
||||||
testNetwork(done, params);
|
testNetwork(done, params);
|
||||||
});
|
});
|
||||||
it('Allows selection of Whitecoin', function(done) {
|
it('Allows selection of Whitecoin Classic', function(done) {
|
||||||
var params = {
|
var params = {
|
||||||
selectText: "XWC - Whitecoin",
|
selectText: "XWCC - Whitecoin Classic",
|
||||||
phrase: "abandon abandon ability",
|
phrase: "abandon abandon ability",
|
||||||
firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
|
firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
|
||||||
firstPubKey: "03d3f4fa758f6260bfb39664d248a32258b53a90a71224db056ee79abaa3e9f208",
|
firstPubKey: "03d3f4fa758f6260bfb39664d248a32258b53a90a71224db056ee79abaa3e9f208",
|
||||||
@@ -1905,6 +1905,16 @@ it('Allows selection of Whitecoin', function(done) {
|
|||||||
};
|
};
|
||||||
testNetwork(done, params);
|
testNetwork(done, params);
|
||||||
});
|
});
|
||||||
|
it('Allows selection of Whitecoin', function(done) {
|
||||||
|
var params = {
|
||||||
|
selectText: "XWC - Whitecoin",
|
||||||
|
phrase: "abandon abandon ability",
|
||||||
|
firstAddress: "XWCNY5EQsC55ifxRVEbP7H28yc3TMXC2pqsb5",
|
||||||
|
firstPubKey: "XWC68fEy4cCc8G1UWyeMPnQ5NjEhMUFSvu1oz4gLKxvj3dPvh7v18",
|
||||||
|
firstPrivKey: "5K8toD6TYy5DMHkxjpywXNLj4M6CjZAT5h12uhRuVuBBRtci8Zw",
|
||||||
|
};
|
||||||
|
testNetwork(done, params);
|
||||||
|
});
|
||||||
it('Allows selection of Wincoin', function(done) {
|
it('Allows selection of Wincoin', function(done) {
|
||||||
var params = {
|
var params = {
|
||||||
selectText: "WC - Wincoin",
|
selectText: "WC - Wincoin",
|
||||||
|
|||||||
Reference in New Issue
Block a user