Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

Commit 85f91e7

Browse files
committed
Fix generateAddress
Signed-off-by: Sina Mahmoodi <[email protected]>
1 parent 64eccff commit 85f91e7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,16 @@ export const isValidChecksumAddress = function(address: string): boolean {
481481
*/
482482
export const generateAddress = function(from: Buffer, nonce: Buffer): Buffer {
483483
from = toBuffer(from)
484+
const nonceBN = new BN(nonce)
484485

485-
if (new BN(nonce).isZero()) {
486+
if (nonceBN.isZero()) {
486487
// in RLP we want to encode null in the case of zero nonce
487488
// read the RLP documentation for an answer if you dare
488489
return rlphash([from, null]).slice(-20)
489490
}
490491

491492
// Only take the lower 160bits of the hash
492-
return rlphash([from, nonce]).slice(-20)
493+
return rlphash([from, Buffer.from(nonceBN.toArray())]).slice(-20)
493494
}
494495

495496
/**

0 commit comments

Comments
 (0)