Skip to content

fix(sdk-coin-eth): guard BN construction in signFinal for EIP-1559 txns#9125

Draft
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
masterfrom
coins-572/fix-eip1559-signfinal-tostring
Draft

fix(sdk-coin-eth): guard BN construction in signFinal for EIP-1559 txns#9125
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
masterfrom
coins-572/fix-eip1559-signfinal-tostring

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown

What

  • In Eth.signFinal (modules/sdk-coin-eth/src/eth.ts), skip new BN(txPrebuild.gasPrice) when the transaction uses EIP-1559 (i.e. txPrebuild.eip1559 is set), passing undefined instead
  • Add WRWUnsignedSweepEIP1559ETHTx fixture and a test that exercises isLastSignature=true with an EIP-1559 prebuild to prevent regression

Why

  • When a user raises (increases) fees on a pending EIP-1559 Ethereum transaction, the SDK calls signFinal with isLastSignature: true. EIP-1559 prebuilds carry maxFeePerGas/maxPriorityFeePerGas instead of gasPrice, so txPrebuild.gasPrice is undefined. The bn.js constructor calls .toString() on its argument internally, which throws Cannot read properties of undefined (reading 'toString') and prevents the fee-raise from completing.
  • buildTransaction already handles EIP-1559 correctly by ignoring gasPrice when eip1559 is present, so passing undefined for gasPrice in the EIP-1559 branch is safe.

Test plan

  • New unit test: should add a second EIP-1559 signature to unsigned sweep for teth without throwing when gasPrice is absent — confirms the crash is fixed
  • yarn unit-test --scope @bitgo/sdk-coin-eth — all 362 tests pass
  • yarn unit-test --scope @bitgo/abstract-eth — all 138 tests pass

Ticket: COINS-572

Support Bot added 2 commits June 26, 2026 14:16
Session-Id: afc68d99-c916-424d-bffc-d814dea1d611
Task-Id: 60985a53-c0de-4df0-9fb9-187bad6e4464
In Eth.signFinal (the second-signature path for WRW/offline-vault
transactions), the ethTxParams object was unconditionally calling
`new BN(txPrebuild.gasPrice)`. For EIP-1559 transactions, gasPrice
is absent from txPrebuild, so bn.js received undefined and threw
"Cannot read properties of undefined (reading 'toString')" internally.

The buildTransaction helper already handles EIP-1559 correctly by
consuming maxFeePerGas/maxPriorityFeePerGas from the eip1559 field and
ignoring gasPrice when eip1559 is present, so passing undefined is safe.

The fix skips BN construction when txPrebuild.eip1559 is set, preventing
the crash when users raise fees on EIP-1559 Ethereum transactions.

Added a WRWUnsignedSweepEIP1559ETHTx fixture and a corresponding test
that exercises the isLastSignature=true path with an EIP-1559 txPrebuild
(no gasPrice field).

Ticket: COINS-572
Session-Id: afc68d99-c916-424d-bffc-d814dea1d611
Task-Id: 60985a53-c0de-4df0-9fb9-187bad6e4464
@linear-code

linear-code Bot commented Jun 26, 2026

Copy link
Copy Markdown

COINS-572

@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot force-pushed the coins-572/fix-eip1559-signfinal-tostring branch from 72ce4df to d65632f Compare June 26, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants