mirror of
https://github.com/AtHeartEngineer/bip39.git
synced 2026-01-09 09:27:59 -05:00
change xwc to xwcc,add new xwc
This commit is contained in:
@@ -1104,6 +1104,7 @@
|
||||
<script src="js/cosmos-util.js"></script>
|
||||
<script src="js/eos-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/wordlist_english.js"></script>
|
||||
<script src="js/wordlist_japanese.js"></script>
|
||||
|
||||
@@ -1424,6 +1424,12 @@
|
||||
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer());
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
//Groestlcoin Addresses are different
|
||||
if(isGRS()) {
|
||||
@@ -3568,7 +3574,7 @@
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XWC - Whitecoin",
|
||||
name: "XWCC - Whitecoin Classic",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.whitecoin;
|
||||
setHdCoin(155);
|
||||
@@ -3609,6 +3615,13 @@
|
||||
setHdCoin(121);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "XWC - Whitecoin",
|
||||
onSelect: function() {
|
||||
network = libs.bitcoin.networks.bitcoin;
|
||||
setHdCoin(559);
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1877,7 +1877,7 @@ it('Allows selection of VeChain', function(done) {
|
||||
});
|
||||
it('Allows selection of Whitecoin', function(done) {
|
||||
var params = {
|
||||
selectText: "XWC - Whitecoin",
|
||||
selectText: "XWCC - Whitecoin Classic",
|
||||
phrase: "abandon abandon ability",
|
||||
firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
|
||||
firstPubKey: "03d3f4fa758f6260bfb39664d248a32258b53a90a71224db056ee79abaa3e9f208",
|
||||
@@ -1885,6 +1885,16 @@ it('Allows selection of Whitecoin', function(done) {
|
||||
};
|
||||
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) {
|
||||
var params = {
|
||||
selectText: "WC - Wincoin",
|
||||
|
||||
Reference in New Issue
Block a user