From ef17dd1b64ba623a0205f061f8f9d678d1104382 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Sat, 27 Feb 2021 15:34:12 +0100 Subject: [PATCH] tx: add support for very high `v` values --- packages/tx/src/legacyTransaction.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/tx/src/legacyTransaction.ts b/packages/tx/src/legacyTransaction.ts index e88ed36a80..8be277098c 100644 --- a/packages/tx/src/legacyTransaction.ts +++ b/packages/tx/src/legacyTransaction.ts @@ -255,7 +255,7 @@ export default class LegacyTransaction extends BaseTransaction= 2,675,000 and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36, then when computing the hash of a transaction for purposes of signing or recovering, instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data), hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0. - const v = this.v?.toNumber() + const v = this.v! + + const chainIdDoubled = new BN(this.getChainId().toString()).imuln(2) const vAndChainIdMeetEIP155Conditions = - v === this.getChainId() * 2 + 35 || v === this.getChainId() * 2 + 36 + v.eq(chainIdDoubled.addn(35)) || v.eq(chainIdDoubled.addn(36)) return vAndChainIdMeetEIP155Conditions && onEIP155BlockOrLater }