on master help sign in
wallet: make publicToAddress more robust

Apparently Uint8Arrays aren't quite enough like Buffers as far as ethereumjs-util is concerned. Here we make sure we always pass in a Buffer by creating one from whatever argument was passed in. Arguably this needs fixing as the callsites instead, happy to discuss. Fixes #604.

commitb4b2aee993f5039064021ed880dbbddb2fd79790 authorFang <git@fang.io> dateMon 16 Aug 2021, 14:44 (5 years ago) parent08a6c15
1 file changed+1−1
src/lib/utils/address.ts+1−1
src/lib/utils/address.ts+1−1
@@ -35,5 +35,5 @@ export const eqAddr = (addr0, addr1) =>
3535 toChecksumAddress(addr0) === toChecksumAddress(addr1);
3636
3737export const publicToAddress = (publicKey: Buffer): string => {
38− return toHex(pubToAddress(publicKey, true).toString('hex'));
38+ return '0x' + pubToAddress(Buffer.from(publicKey), true).toString('hex');
3939};