Adds numberFormat to txps#4176
Open
kajoseph wants to merge 11 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses tx proposal signing/verifying failures caused by large-number precision/rounding differences between React Native and Node.js runtimes by introducing a deterministic number formatting option (notably hex) across BWS/BWC txp APIs and formatting tx-build-relevant fields consistently.
Changes:
- Added
TxProposal.formatNumbers()plusnumberFormatplumbing through BWS APIs (create/publish/prepare/getPendingTxs/sign) and updated BWC to requestnumberFormat=hex. - Updated locked-balance calculations for EVM/XRP/SOL to use
BigIntwhen summing pending tx amounts/fees. - Fixed CWC
isHexStringto accept odd-length hex strings by 0-padding, and updated/added related tests and typings.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/crypto-wallet-core/src/utils/index.ts | Adjusts isHexString to 0-pad odd-length hex strings before validation. |
| packages/crypto-wallet-core/test/utils.test.ts | Adds coverage for odd-length hex validation behavior. |
| packages/bitcore-wallet-service/src/lib/model/txproposal.ts | Introduces generic numeric typing + formatNumbers() and threads numberFormat into raw-tx creation/signing paths. |
| packages/bitcore-wallet-service/src/lib/model/txproposal_legacy.ts | Renames legacy interface and aligns broadcastedOn typing. |
| packages/bitcore-wallet-service/src/lib/model/txnote.ts | Adds non-persisted editedByName field for fetch-time enrichment. |
| packages/bitcore-wallet-service/src/lib/server.ts | Adds numberFormat support to multiple txp endpoints and adjusts pending-tx retrieval wiring. |
| packages/bitcore-wallet-service/src/lib/routes/wallets.ts | Passes numberFormat from query params into status/build options. |
| packages/bitcore-wallet-service/src/lib/routes/transactions.ts | Adds numberFormat query propagation into txp list/create/sign/prepare/publish routes. |
| packages/bitcore-wallet-service/src/lib/storage.ts | Typing improvements and replaces lodash iteration with for..of loops in completion helpers. |
| packages/bitcore-wallet-service/src/lib/chain/index.ts | Broadens txp typing for getBitcoreTx plumbing. |
| packages/bitcore-wallet-service/src/lib/chain/eth/index.ts | Uses BigInt when summing locked pending amounts/fees. |
| packages/bitcore-wallet-service/src/lib/chain/sol/index.ts | Uses BigInt when summing locked pending amounts/fees. |
| packages/bitcore-wallet-service/src/lib/chain/xrp/index.ts | Uses BigInt when summing locked pending amounts/fees. |
| packages/bitcore-wallet-service/test/model/txproposal.test.ts | Adds tests for formatNumbers and updates fixtures/typing expectations. |
| packages/bitcore-wallet-service/test/chain/{btc,bch,ltc,doge,xrp}.test.ts | Updates fixtures/typing to match updated txp shape and numeric handling. |
| packages/bitcore-wallet-client/src/lib/api.ts | Adds numberFormat=hex to relevant txp API calls (list/publish/sign/prepare/status). |
| packages/bitcore-wallet-client/src/lib/bulkclient.ts | Adds numberFormat=hex to bulk status requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…andled correctly in SPL
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.
Description
There is a lingering bug where signing transaction proposals, particularly EVM, would fail with an error
Server response could not be verified. Turns out, this is due to large number rounding slightly differing between the React Native and NodeJS runtimes.Changelog
formatNumbersfunction to TxProposal modelnumberFormatoptions to signing functionnumberFormatto relevant APIsnumberFormat=hexquery param to BWC methodsisHexStringmethod to 0-pad odd-length hex stringsTesting Notes
Create a multi-recipient EVM tx proposal with one recipient receiving 53361793000000000000 (hex: 0x2e48b2c02b6ed0000) and the other 64034152000000010000 (hex: 0x378a701f9fd5ea000). Signing the txp in the app should result in the
Server response could not be verifiederror. ❌Then, using this branch of the bitpay-app, point the app's bitcore-wallet-client to this branch's BWC and try signing the proposal - it should succeed. ✔️
Checklist