Skip to content

Conversation

@xbuddhi
Copy link

@xbuddhi xbuddhi commented Jul 14, 2025

PR Type

Enhancement, Bug fix, Documentation


Description

Centralized satoshi formatting: Added new utils.FormatSats() function with thousands separators and proper unit handling ("sat" vs "sats")
Comprehensive formatting implementation: Updated all payment-related messages across Telegram handlers, API endpoints, and LNURL functionality to use formatted amounts
New convert command: Added /convert command for satoshi to fiat (USD/LKR) conversion with proper formatting
Translation updates: Updated all language files to use string format specifiers (%s) instead of integer (%d) for amount display
Deployment refactoring: Changed build process from GitHub Actions to server-side execution
Bug fix: Corrected log format specifier in database migration from %d to %s for user ID
Documentation: Added convert command documentation and BotFather configuration
Testing utilities: Added API payment testing script with HMAC authentication


Changes walkthrough 📝

Relevant files
Enhancement
31 files
api_approval.go
Replace hardcoded satoshi formatting with utils.FormatSats in API
approval

internal/telegram/api_approval.go

• Added import for internal/utils package
• Replaced hardcoded satoshi
formatting with utils.FormatSats() function calls
• Updated error
messages, log messages, and notification messages to use formatted
satoshi display
• Modified approval request messages to show formatted
amounts with proper units

+8/-7     
send.go
Implement formatted satoshi display in API send functionality

internal/api/send.go

• Added import for internal/utils package
• Updated API error messages
to use utils.FormatSats() for amount formatting
• Modified
insufficient balance error messages to display formatted satoshi
amounts
• Updated approval threshold messages and notification
messages with formatted amounts

+8/-7     
error_logger.go
Refactor error logging to use centralized satoshi formatting

internal/telegram/error_logger.go

• Added import for internal/utils package
• Removed local formatSats()
function implementation
• Updated payment and transaction error
logging to use utils.FormatSats()
• Modified error message formatting
to use centralized formatting function

+5/-28   
shop.go
Apply formatted satoshi display to shop functionality       

internal/telegram/shop.go

• Added import for internal/utils package
• Updated shop item price
display to use utils.FormatSats()
• Modified purchase confirmation and
transaction messages with formatted amounts
• Updated log messages to
display formatted satoshi values

+5/-4     
groups.go
Implement formatted amounts in group ticket functionality

internal/telegram/groups.go

• Added import for internal/utils package
• Updated group ticket
invoice messages to use utils.FormatSats()
• Modified group creation
messages to display formatted ticket prices
• Applied formatting to
commission and payment notification messages

+4/-3     
amounts.go
Format amount ranges and validation messages                         

internal/telegram/amounts.go

• Added import for internal/utils package
• Updated amount range
validation messages to use utils.FormatSats()
• Modified user prompts
for amount entry to display formatted ranges
• Applied formatting to
error messages for invalid amount ranges

+3/-2     
shop_helpers.go
Format shop item prices and purchase buttons                         

internal/telegram/shop_helpers.go

• Added import for internal/utils package
• Updated shop item buy
button text to use utils.FormatSats()
• Modified purchase confirmation
menu to display formatted prices
• Applied formatting to shop item
display text

+3/-2     
number_format.go
Add centralized satoshi formatting utility function           

internal/utils/number_format.go

• Added new FormatSats() function for formatting satoshi amounts with
thousands separators
• Implemented support for optional plus sign
display for positive amounts
• Added proper singular/plural unit
handling ("sat" vs "sats")
• Improved code formatting and structure
for existing FormatFloatWithCommas() function

+57/-24 
tooltip.go
Format tip amounts in tooltip messages                                     

internal/telegram/tooltip.go

• Added import for internal/utils package
• Updated tip tooltip
messages to use utils.FormatSats()
• Modified tip amount display in
tooltip messages
• Applied formatting to new tooltip creation messages

+4/-3     
inline_send.go
Apply LKR formatting to inline send messages                         

internal/telegram/inline_send.go

• Updated inline send messages to use thirdparty.FormatSatsWithLKR()
instead of raw amounts
• Modified acceptance and notification messages
to display formatted amounts
• Applied consistent formatting to sender
and receiver confirmation messages

+3/-3     
balance.go
Format balance display with proper satoshi formatting       

internal/telegram/balance.go

• Updated balance display message to use utils.FormatSats()
• Modified
log message to show formatted balance amounts
• Applied formatting to
balance handler output

+12/-12 
inline_receive.go
Apply LKR formatting to inline receive functionality         

internal/telegram/inline_receive.go

• Updated inline receive messages to use
thirdparty.FormatSatsWithLKR()
• Modified acceptance and notification
messages with formatted amounts
• Applied consistent LKR formatting to
receiver and sender messages

+3/-3     
lnurl-pay.go
Format LNURL pay amount validation messages                           

internal/telegram/lnurl-pay.go

• Added import for internal/utils package
• Updated LNURL pay amount
range validation messages to use utils.FormatSats()
• Modified error
messages to display formatted amount ranges

+2/-1     
lnurl-withdraw.go
Format LNURL withdraw amount validation messages                 

internal/telegram/lnurl-withdraw.go

• Added import for internal/utils package
• Updated LNURL withdraw
amount range validation to use utils.FormatSats()
• Modified error
messages to display formatted withdrawal limits

+2/-1     
faucet.go
Format faucet amounts and summary display                               

internal/telegram/faucet.go

• Added import for internal/utils package
• Updated faucet summary
display to use utils.FormatSats()
• Modified faucet capacity and
remaining amount messages with formatting

+2/-1     
convertsats.go
Add new satoshi to fiat conversion command                             

internal/telegram/convertsats.go

• New file implementing satoshi to fiat conversion functionality

Added /convert command handler for converting sats to USD and LKR

Implemented input validation and error handling for conversion amounts

• Used utils.FormatSats() and utils.FormatFloatWithCommas() for
display formatting

+43/-0   
ticket.go
Format ticket payment amounts in group functionality         

internal/telegram/ticket.go

• Added import for internal/utils package
• Updated ticket payment
requirement message to use utils.FormatSats()
• Modified group join
payment notification with formatted amounts

+2/-1     
tipjar.go
Format tipjar amounts and summary display                               

internal/telegram/tipjar.go

• Added import for internal/utils package
• Updated tipjar summary
display to use utils.FormatSats()
• Modified tipjar capacity and
collected amount messages with formatting

+2/-1     
lnurl.go
Format LNURL payment validation error messages                     

internal/lnurl/lnurl.go

• Added import for internal/utils package
• Updated LNURL payment
amount validation error messages to use utils.FormatSats()
• Modified
out-of-bounds error messages to display formatted amount ranges

+2/-1     
transactions.go
Format transaction amounts and fees in transaction history

internal/telegram/transactions.go

• Added import for internal/utils package
• Updated transaction list
display to use utils.FormatSats() with plus sign for amounts

Modified fee display in transaction history with formatted amounts

+3/-2     
pending_transactions.go
Format amounts in admin pending transaction notifications

internal/api/admin/pending_transactions.go

• Added import for internal/utils package
• Updated admin notification
messages to use utils.FormatSats()
• Modified pending transaction
execution notifications with formatted amounts

+2/-1     
webhook.go
Format webhook invoice amounts in notifications                   

internal/lnbits/webhook/webhook.go

• Added import for internal/utils package
• Updated webhook invoice
received message to use utils.FormatSats()
• Modified fallback
notification message with formatted amounts

+2/-1     
lkrsats.go
Format LKR to satoshi conversion results                                 

internal/telegram/lkrsats.go

• Added import for internal/utils package
• Updated LKR to satoshi
conversion result message to use formatted functions
• Applied
utils.FormatFloatWithCommas() and utils.FormatSats() to conversion
output

+2/-1     
buttons.go
Format balance display in main menu buttons                           

internal/telegram/buttons.go

• Updated main menu balance button to use
thirdparty.FormatSatsWithLKR()
• Modified balance display in main menu
with LKR formatting

+1/-1     
handler.go
Register new convert command handler                                         

internal/telegram/handler.go

• Added new /convert command endpoint configuration
• Registered
satToFiatHandler for the convert command
• Applied standard
interceptors for private chat, localization, and logging

+11/-0   
coingecko.go
Integrate centralized formatting in LKR display function 

internal/thirdparty/coingecko.go

• Updated FormatSatsWithLKR() function to use utils.FormatSats()

Modified fallback formatting to use centralized formatting function

Applied consistent formatting to LKR value display

+2/-2     
pl.toml
Update Polish translations for formatted amount display   

translations/pl.toml

• Updated Polish translation strings to use %s format specifiers
instead of %d
• Modified amount-related messages to support formatted
string display
• Applied consistent formatting placeholders across all
amount references

+38/-38 
cs.toml
Update Czech translations for formatted amount display     

translations/cs.toml

• Updated Czech translation strings to use %s format specifiers
instead of %d
• Modified amount-related messages to support formatted
string display
• Applied consistent formatting placeholders across all
amount references

+38/-38 
fi.toml
Update Finnish translations for formatted amount display 

translations/fi.toml

• Updated Finnish translation strings to use %s format specifiers
instead of %d
• Modified amount-related messages to support formatted
string display
• Applied consistent formatting placeholders across all
amount references

+38/-38 
de.toml
Update German translations for formatted amount display   

translations/de.toml

• Updated German translation strings to use %s format specifiers
instead of %d
• Modified amount-related messages to support formatted
string display
• Added new convertSatsResultMessage translation for
satoshi conversion

+38/-35 
en.toml
Update English translations for formatted amount display 

translations/en.toml

• Updated English translation strings to use %s format specifiers
instead of %d
• Modified amount-related messages to support formatted
string display
• Added new convertSatsResultMessage translation for
satoshi to fiat conversion

+7/-4     
Bug fix
1 files
migrations.go
Fix log format specifier in database migration                     

internal/database/migrations.go

• Fixed log message format specifier from %d to %s for user ID

Corrected string formatting in migration log output

+1/-1     
Miscellaneous
1 files
test_pay_api.sh
Add API payment testing script                                                     

test_pay_api.sh

• New shell script for testing API payment functionality
• Implements
HMAC signature generation for API authentication
• Provides example
curl command for testing payment endpoints

+26/-0   
Configuration changes
2 files
build-deploy.yml
Refactor deployment to build application on server             

.github/workflows/build-deploy.yml

• Moved application build process from GitHub Actions to server-side
execution
• Updated deployment workflow to transfer source code
instead of pre-built binary
• Modified deployment steps to build
application on target server

+9/-18   
botfather-setcommands.txt
Add convert command to BotFather configuration                     

botfather-setcommands.txt

• Added new convert command definition for BotFather configuration

Included description for satoshi to fiat conversion functionality

+1/-0     
Formatting
9 files
config.yaml.example
Minor formatting fix in config example                                     

config.yaml.example

• Removed trailing newline from configuration file
• Minor formatting
adjustment to file ending

+1/-1     
ru.toml
Update Russian translation amount formatting from integer to string

translations/ru.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Applied consistent string formatting
across all payment-related message templates

+33/-33 
es.toml
Update Spanish translation amount formatting from integer to string

translations/es.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Added new convertSatsResultMessage for
sat to fiat conversion display

+38/-35 
pt-br.toml
Update Portuguese (Brazil) translation amount formatting from integer
to string

translations/pt-br.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Applied consistent string formatting
across all payment-related message templates

+35/-35 
it.toml
Update Italian translation amount formatting from integer to string

translations/it.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Added new convertSatsResultMessage for
sat to fiat conversion display

+32/-29 
id.toml
Update Indonesian translation amount formatting from integer to string

translations/id.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Applied consistent string formatting
across all payment-related message templates

+29/-29 
tr.toml
Update Turkish translation amount formatting from integer to string

translations/tr.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Applied consistent string formatting
across all payment-related message templates

+28/-28 
nl.toml
Update Dutch translation amount formatting from integer to string

translations/nl.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Added new convertSatsResultMessage for
sat to fiat conversion display

+31/-28 
fr.toml
Update French translation amount formatting from integer to string

translations/fr.toml

• Changed format specifiers from %d to %s for amount display in
balance, tip, send, invoice, and faucet messages
• Updated currency
amount formatting to use string placeholders instead of integer
formatting
• Modified range validation messages to use string
formatting for min/max values
• Applied consistent string formatting
across all payment-related message templates

+28/-28 
Documentation
1 files
README.md
Document new convert command in README                                     

README.md

• Added documentation for new /convert command
• Updated command list
to include satoshi to fiat conversion functionality

+1/-0     
Additional files
1 files
hmac_client.go +0/-140 

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • ceyvibes and others added 20 commits July 11, 2025 13:35
    fix: Update source path in deployment workflow to include all files
    fix: Update file source patterns in deployment workflow to include hi…
    * Add thousand separators for satoshi amounts
    
    * Refactor error logger formatting
    
    * add plus sign option for FormatSats
    * fix: add sat formattings
    
    * fix: more missed templates
    
    * fix: more missed templates
    
    * fix: more missed templates
    @coderabbitai
    Copy link

    coderabbitai bot commented Jul 14, 2025

    Important

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


    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
    🪧 Tips

    Chat

    There are 3 ways to chat with CodeRabbit:

    • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
      • I pushed a fix in commit <commit_id>, please review it.
      • Explain this complex logic.
      • Open a follow-up GitHub issue for this discussion.
    • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
      • @coderabbitai explain this code block.
      • @coderabbitai modularize this function.
    • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
      • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
      • @coderabbitai read src/utils.ts and explain its main purpose.
      • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
      • @coderabbitai help me debug CodeRabbit configuration file.

    Support

    Need help? Create a ticket on our support page for assistance with any issues or questions.

    Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

    CodeRabbit Commands (Invoked using PR comments)

    • @coderabbitai pause to pause the reviews on a PR.
    • @coderabbitai resume to resume the paused reviews.
    • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
    • @coderabbitai full review to do a full review from scratch and review all the files again.
    • @coderabbitai summary to regenerate the summary of the PR.
    • @coderabbitai generate docstrings to generate docstrings for this PR.
    • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
    • @coderabbitai resolve resolve all the CodeRabbit review comments.
    • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
    • @coderabbitai help to get help.

    Other keywords and placeholders

    • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
    • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
    • Add @coderabbitai anywhere in the PR title to generate the title automatically.

    CodeRabbit Configuration File (.coderabbit.yaml)

    • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
    • Please see the configuration documentation for more information.
    • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

    Documentation and Community

    • Visit our Documentation for detailed information on how to use CodeRabbit.
    • Join our Discord Community to get help, request features, and share feedback.
    • Follow us on X/Twitter for updates and announcements.

    @xbuddhi xbuddhi changed the title updating thr dev updating the dev Jul 14, 2025
    @xbuddhi xbuddhi merged commit 0c4161c into dev Jul 14, 2025
    2 checks passed
    @qodo-code-review qodo-code-review bot changed the title updating the dev updating thr dev Jul 14, 2025
    @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Issue

    The FormatSats function uses variadic parameters for withPlus but doesn't validate the input properly. The function could behave unexpectedly if multiple boolean values are passed.

    func FormatSats(amount int64, withPlus ...bool) string {
    	showPlus := false
    	if len(withPlus) > 0 {
    		showPlus = withPlus[0]
    	}
    Input Validation

    The satToFiatHandler function lacks proper input validation for the amount parameter. It only checks if parsing fails or if the value is <= 0, but doesn't validate upper bounds or handle potential overflow scenarios.

    amountStr := strings.ReplaceAll(args[1], ",", "")
    sats, err := strconv.ParseInt(amountStr, 10, 64)
    if err != nil || sats <= 0 {
    	bot.trySendMessage(m.Sender, Translate(ctx, "convertInvalidAmountMessage"))
    	return ctx, nil
    }
    Format Specifier

    The log format specifier was changed from %d to %s for user ID, but the actual data type being logged (u.ID) should be verified to ensure it's compatible with string formatting.

    log.Infof("[MigrateAnonIdInt32Hash] %s -> %d", u.ID, str.Int32Hash(u.ID))
    u.AnonID = fmt.Sprint(str.Int32Hash(u.ID))

    @qodo-code-review
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix inconsistent format specifier

    The format specifier %d was not updated to %s in this line, which is
    inconsistent with the other changes in the same file. This could cause
    formatting errors when displaying amounts.

    translations/nl.toml [298]

    -inlineSendUpdateMessageAccept  = """💸 %d verzonden van %s naar %s."""
    +inlineSendUpdateMessageAccept  = """💸 %s verzonden van %s naar %s."""
    • Apply / Chat
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies that the format specifier %d in inlineSendUpdateMessageAccept was missed during the update to %s, which could cause a runtime error.

    Medium
    Fix mixed format specifiers

    This line has mixed format specifiers where the capacity uses %s but the
    remaining amount and user counts still use %d. This inconsistency could cause
    formatting issues when displaying faucet status.

    translations/es.toml [280]

    -🚰 Restante: %d/%s (dado a %d/%d usuarios)
    +🚰 Restante: %s/%s (dado a %d/%d usuarios)
    • Apply / Chat
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies an inconsistent use of format specifiers (%d and %s) for amounts in the same line, which could lead to formatting errors.

    Medium
    General
    Fix inconsistent format placeholders

    The format string mixes integer (%d) and string (%s) placeholders
    inconsistently. All amount-related placeholders should use the same format type
    for consistency with the rest of the file changes.

    translations/cs.toml [297]

    -🚰 Zbývá: %d/%s (rozdáno %d/%d uživatelům)
    +🚰 Zbývá: %s/%s (rozdáno %d/%d uživatelům)
    • Apply / Chat
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly identifies an inconsistent format specifier in inlineFaucetMessage where one amount was missed during the update from %d to %s, which aligns with the PR's overall goal.

    Low
    Fix missed format specifier update

    This line still uses the old %d format specifier while all other amount-related
    messages in the file have been updated to use %s. This creates inconsistency in
    the translation.

    translations/ru.toml [297]

    -inlineResultSendDescription     = """👉 Нажмите, чтобы отправить %d сат в этот чат."""
    +inlineResultSendDescription     = """👉 Нажмите, чтобы отправить %s в этот чат."""
    • Apply / Chat
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly points out that inlineResultSendDescription still uses the old %d format specifier for an amount, which was missed in the PR's update to %s for consistency.

    Low
    Remove redundant string formatting calls

    The nested fmt.Sprintf calls are redundant and create unnecessary string
    formatting overhead. The outer fmt.Sprintf("%s", ...) wrapper serves no purpose
    since the inner call already returns a formatted string.

    internal/telegram/inline_send.go [241]

    -inlineSend.Message = fmt.Sprintf("%s", fmt.Sprintf(i18n.Translate(inlineSend.LanguageCode, "inlineSendUpdateMessageAccept"), thirdparty.FormatSatsWithLKR(amount), fromUserStrMd, toUserStrMd))
    +inlineSend.Message = fmt.Sprintf(i18n.Translate(inlineSend.LanguageCode, "inlineSendUpdateMessageAccept"), thirdparty.FormatSatsWithLKR(amount), fromUserStrMd, toUserStrMd)
    • Apply / Chat
    Suggestion importance[1-10]: 5

    __

    Why: The suggestion correctly identifies a redundant fmt.Sprintf call and proposes removing it, which improves code clarity and removes a minor inefficiency.

    Low
    • More

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants