Skip to content

fix(wallet): correct the fiat balance and send the max amount - #417

Merged
nghiacc merged 2 commits into
masterfrom
cursor/fix-wallet-fiat-balance-3c11
Sep 23, 2026
Merged

nghiacc merged 2 commits into
masterfrom
cursor/fix-wallet-fiat-balance-3c11

Conversation

@nghiacc

@nghiacc nghiacc commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What

The wallet balance line multiplied XEC by the placeholder rate { coin: 'xec', rate: 1 } that transformFiatRates adds for self-conversion, then labeled the result with the selected fiat code. 1,556,887.19 XEC therefore showed as ~1,556,887.19 USD.

The balance now uses the selected currency's XEC price (fiat per 1 XEC) from getAllFiatRate. At the current production rate that balance is about 14.24 USD. If that price is missing, the fiat line is omitted instead of showing a 1:1 figure.

The send form has a Max button. It fills the largest amount a P2PKH payment can include after the miner fee, using the same fee rules as the transaction builder. Change that would be below dust is left out, and that value is counted in the fee. The network fee for the entered amount is shown under the field.

After a successful broadcast, the balance drops immediately on the wallet page and in the header. Chronik often still returns the spent coins for a while; those snapshots are ignored until they no longer contain the spent outpoints, and then the balance syncs from the indexer. A partial send keeps the change locally until that sync.

Test

Checked the fiat conversion against a USD group whose XEC rate is 0.00002 (not 1) and against the live getAllFiatRate response, where both the USD and XEC groups report 9.14855882329e-06 USD per XEC.

Compared max, partial, and dust-change quotes with TxBuilder.sign for 1, 2, and 8 inputs. One coin of 1,556,887.19 XEC quotes a max send of 1,556,883.47 XEC and a 3.72 XEC network fee. next build typechecked. The signed-in wallet screen was not opened in a browser.

Open in Web Open in Cursor 

The wallet multiplied the balance by the placeholder XEC rate of 1 and
labeled it as USD. Use the selected currency's XEC price instead.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c978c4dc-7281-4916-8a7a-220661064138

📥 Commits

Reviewing files that changed from the base of the PR and between f3d17cc and 2ef0bc6.

📒 Files selected for processing (5)
  • apps/telegram-ecash-escrow/src/app/wallet/page.tsx
  • apps/telegram-ecash-escrow/src/components/Send/send.tsx
  • apps/telegram-ecash-escrow/src/store/context/utxoProvider.tsx
  • apps/telegram-ecash-escrow/src/store/util.ts
  • apps/telegram-ecash-escrow/src/store/walletSend.ts
 _________________________________________________________________
< I am below the bugs. I am above the bugs. I am around the bugs. >
 -----------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Max fills the largest amount the miner fee leaves spendable. After a broadcast, the wallet subtracts those coins locally and ignores Chronik snapshots that still include them.
@cursor cursor Bot changed the title fix(wallet): stop showing the XEC balance as 1:1 fiat fix(wallet): correct the fiat balance and send the max amount Sep 23, 2026
@nghiacc
nghiacc marked this pull request as ready for review September 23, 2026 21:43
@nghiacc
nghiacc merged commit dfd38a2 into master Sep 23, 2026
4 checks passed
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.

2 participants