Skip to content

fix: p2p amount_lkr is a bare number kept from send time - #231

Closed
helloscoopa wants to merge 1 commit into
mainfrom
scoopa/p2p-amount-lkr
Closed

helloscoopa wants to merge 1 commit into
mainfrom
scoopa/p2p-amount-lkr

Conversation

@helloscoopa

Copy link
Copy Markdown
Member

Problem

The Mini App's Sent screen showed Value ≈ රු. 0.00 for every P2P send (reported for a 1 sat send that was worth රු. 0.21).

toTransferResponse, the collect response and /p2p/decode built amount_lkr with thirdparty.FormatSatsWithLKR, which returns a display string ("1 sats (රු. 0.21)"). The app expects a bare number like every other amount_lkr the bot returns (getLKRValue, "1,234.56"). It parsed the string to NaN, which then displayed as 0.00.

The value was also recalculated at the current price on every read, so "View payment" days later showed what the sats were worth that day, not when they were sent.

Change

  • amount_lkr (transfers, collects, decode) and balance_lkr (/p2p/me) are bare numbers again.
  • P2PTransfer gets AmountLKR, set once when the transfer starts (internal sends, invoice payments, and collect payments), so the transfer keeps its value from that moment.
  • Older transfers have no stored value and fall back to today's price, the same as before.

The app side (which reads both shapes, so it works before this deploys) is in bitcoindeepa/app-frontend scoopa/sat-pluralization-lkr-value.

Checks

  • go build ./... and go vet on internal/api and internal/telegram pass. The full test suite is left to CI.

Generated by Claude Code

The Mini App's transfer, collect and decode responses sent
amount_lkr as a display string ("1 sats (රු. 0.21)"), so the app
showed රු. 0.00. Send the bare number like every other endpoint.

Each transfer now keeps its rupee value from when it started, so
View payment shows what it was worth then, not at today's price.
Older transfers fall back to today's price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBZc7g7p7xCjG3aia1WorB

Copy link
Copy Markdown
Member Author

Closing in favour of bitcoindeepa/app-backend#159.

The app now gets a send's value from the backend: our exchange_rate_log rate at the transfer's created_at. That's the same BTC/LKR the app quoted, and it also covers sends made before this change (back to 23 Nov). Saving the value here would use the bot's own price feed, which doesn't match the app's, and would only cover new sends.

The app no longer reads amount_lkr from these responses, so the display-string format doesn't affect it anymore.


Generated by Claude Code

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