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
Draft
fix(sdk-coin-eth): guard BN construction in signFinal for EIP-1559 txns#9125bitgo-ai-agent-dev[bot] wants to merge 2 commits into
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
Conversation
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
72ce4df to
d65632f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Eth.signFinal(modules/sdk-coin-eth/src/eth.ts), skipnew BN(txPrebuild.gasPrice)when the transaction uses EIP-1559 (i.e.txPrebuild.eip1559is set), passingundefinedinsteadWRWUnsignedSweepEIP1559ETHTxfixture and a test that exercisesisLastSignature=truewith an EIP-1559 prebuild to prevent regressionWhy
signFinalwithisLastSignature: true. EIP-1559 prebuilds carrymaxFeePerGas/maxPriorityFeePerGasinstead ofgasPrice, sotxPrebuild.gasPriceisundefined. Thebn.jsconstructor calls.toString()on its argument internally, which throwsCannot read properties of undefined (reading 'toString')and prevents the fee-raise from completing.buildTransactionalready handles EIP-1559 correctly by ignoringgasPricewheneip1559is present, so passingundefinedforgasPricein the EIP-1559 branch is safe.Test plan
should add a second EIP-1559 signature to unsigned sweep for teth without throwing when gasPrice is absent— confirms the crash is fixedyarn unit-test --scope @bitgo/sdk-coin-eth— all 362 tests passyarn unit-test --scope @bitgo/abstract-eth— all 138 tests passTicket: COINS-572