@profullstack/coinpay 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/coinpay.js +1 -1
- package/package.json +1 -1
- package/src/wallet.js +10 -5
package/bin/coinpay.js
CHANGED
package/package.json
CHANGED
package/src/wallet.js
CHANGED
|
@@ -154,11 +154,11 @@ function deriveBCHAddress(compressedPubKey) {
|
|
|
154
154
|
checksumInput.set(prefixData);
|
|
155
155
|
checksumInput.set(payload5, prefixData.length);
|
|
156
156
|
// Last 8 bytes are zeros for checksum calculation
|
|
157
|
-
const polymod = cashAddrPolymod(checksumInput) ^
|
|
157
|
+
const polymod = cashAddrPolymod(checksumInput) ^ 1n;
|
|
158
158
|
|
|
159
159
|
const checksum = new Uint8Array(8);
|
|
160
160
|
for (let i = 0; i < 8; i++) {
|
|
161
|
-
checksum[i] = (polymod >> (5 * (7 - i))) &
|
|
161
|
+
checksum[i] = Number((polymod >> BigInt(5 * (7 - i))) & 0x1fn);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
let encoded = 'bitcoincash:';
|
|
@@ -210,7 +210,7 @@ function cashAddrPolymod(values) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
return
|
|
213
|
+
return c;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
/**
|
|
@@ -222,9 +222,14 @@ function deriveETHAddress(compressedPubKey) {
|
|
|
222
222
|
const uncompressed = point.toRawBytes(false); // 65 bytes with 04 prefix
|
|
223
223
|
// Keccak256 of the 64 bytes (without 04 prefix)
|
|
224
224
|
const hash = keccak_256(uncompressed.slice(1));
|
|
225
|
-
// Last 20 bytes
|
|
225
|
+
// Last 20 bytes — EIP-55 checksummed
|
|
226
226
|
const addr = bytesToHex(hash.slice(12));
|
|
227
|
-
|
|
227
|
+
const addrHash = bytesToHex(keccak_256(new TextEncoder().encode(addr)));
|
|
228
|
+
let checksummed = '';
|
|
229
|
+
for (let i = 0; i < addr.length; i++) {
|
|
230
|
+
checksummed += parseInt(addrHash[i], 16) >= 8 ? addr[i].toUpperCase() : addr[i];
|
|
231
|
+
}
|
|
232
|
+
return '0x' + checksummed;
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
/**
|