diff --git a/src/index.html b/src/index.html
index 0588171..cc84247 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1104,6 +1104,7 @@
+
diff --git a/src/js/index.js b/src/js/index.js
index 4e55511..2235be4 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -1425,6 +1425,12 @@
pubkey = CosmosBufferToPublic(keyPair.getPublicKeyBuffer(), hrp);
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") {
const hrp = "terra";
@@ -3597,7 +3603,7 @@
},
},
{
- name: "XWC - Whitecoin",
+ name: "XWCC - Whitecoin Classic",
onSelect: function() {
network = libs.bitcoin.networks.whitecoin;
setHdCoin(155);
@@ -3638,6 +3644,13 @@
setHdCoin(121);
},
},
+ {
+ name: "XWC - Whitecoin",
+ onSelect: function() {
+ network = libs.bitcoin.networks.bitcoin;
+ setHdCoin(559);
+ },
+ }
]
var clients = [
diff --git a/src/js/xwc-util.js b/src/js/xwc-util.js
new file mode 100644
index 0000000..fc47d05
--- /dev/null
+++ b/src/js/xwc-util.js
@@ -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);
+}
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index 3b8a053..87ecb55 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -1895,9 +1895,9 @@ it('Allows selection of VeChain', function(done) {
};
testNetwork(done, params);
});
-it('Allows selection of Whitecoin', function(done) {
+it('Allows selection of Whitecoin Classic', function(done) {
var params = {
- selectText: "XWC - Whitecoin",
+ selectText: "XWCC - Whitecoin Classic",
phrase: "abandon abandon ability",
firstAddress: "WcSwCAUqrSgeSYbsaS3SSWWhsx8KRYTFDR",
firstPubKey: "03d3f4fa758f6260bfb39664d248a32258b53a90a71224db056ee79abaa3e9f208",
@@ -1905,6 +1905,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",