]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - src/js/bitcoinjs-extensions.js
new Crown address format. May not be elegant solution, but bitcoinjs has limitation...
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / src / js / bitcoinjs-extensions.js
index 2b1ecaa2ab61e0e5c7bcb17a2062b9e7cd34315e..e4eef0c1a7b9c59aba4db296599e5437ab4ebafd 100644 (file)
@@ -27,7 +27,7 @@ bitcoinjs.bitcoin.networks.clam = {
     private: 0xa8c17826
   },
   pubKeyHash: 0x89,
-  scriptHash: 0x00, // TODO set this correctly
+  scriptHash: 0x0D,
   wif: 0x85
 };
 
@@ -39,7 +39,27 @@ bitcoinjs.bitcoin.networks.crown = {
   },
   pubKeyHash: 0x00,
   scriptHash: 0x05,
-  wif: 0x80
+  wif: 0x80,
+  toNewAddress: function(oldAddress)
+  {
+    var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
+    var b58 =  basex(ALPHABET);
+
+    var addrBytes = b58.decode(oldAddress);
+
+    var hash160 = new Uint16Array(23); 
+    hash160[0]= 0x01; //C
+    hash160[1]= 0x75; //R
+    hash160[2]= 0x07; //W
+    addrBytes.copy(hash160, 3, 1, 21);
+
+    var checksum = bitcoinjs.bitcoin.crypto.hash256(hash160).subarray(0, 4);
+    var binaryAddr = new Uint16Array(27); 
+    binaryAddr.set(hash160,0);
+    checksum.copy(binaryAddr, 23, 0, 4);
+    var newAddress = b58.encode(binaryAddr);
+    return newAddress;
+  }
 };
 
 bitcoinjs.bitcoin.networks.dash = {
@@ -93,7 +113,7 @@ bitcoinjs.bitcoin.networks.namecoin = {
     private: 0x0488ade4
   },
   pubKeyHash: 0x34,
-  scriptHash: 0x00, // TODO set this correctly
+  scriptHash: 0x0D,
   wif: 0x80
 };
 
@@ -242,14 +262,14 @@ bitcoinjs.bitcoin.networks.myriadcoin = {
 
 
 bitcoinjs.bitcoin.networks.onixcoin = {
-    messagePrefix: 'unused',
+    messagePrefix: 'ONIX Signed Message:\n',
     bip32: {
-      public: 0x049d7cb2,
-      private: 0x049d7878
+      public: 0x0488b21e,
+      private: 0x0488ade4
     },
     pubKeyHash: 0x4B,
     scriptHash: 0x05,
-    wif: 0x80
+    wif: 0xCB
 };
 
 
@@ -261,7 +281,7 @@ bitcoinjs.bitcoin.networks.lkrcoin = {
     },
     pubKeyHash: 0x30,
     scriptHash: 0x55,
-    wif: 0x80
+    wif: 0xB0
 };
 
 bitcoinjs.bitcoin.networks.pivx = {