-
Notifications
You must be signed in to change notification settings - Fork 1
fix: address validation #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…/address-validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements balance validation for Bitcoin and Lightning invoice payments to address issue #354. The changes ensure users receive appropriate error messages when attempting to pay invoices with insufficient balance, invalid addresses, or network mismatches.
Changes:
- Added network validation logic to detect and reject addresses from incompatible Bitcoin networks (mainnet/testnet/regtest)
- Implemented balance validation for both on-chain and Lightning invoices with specific error messages showing the shortfall amount
- Added debounced address validation with immediate user feedback via toast messages
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| NetworkValidationHelper.kt | New utility class for detecting Bitcoin network from address prefixes and validating network compatibility |
| NetworkValidationHelperTest.kt | Comprehensive unit tests covering address network detection and mismatch validation scenarios |
| AppViewModel.kt | Integrated address validation with debouncing, balance checks, and user feedback for both input and scan flows |
| strings.xml | Added new error message string for insufficient spending balance on Lightning invoices |
|
@piotr-iohk needs an update from E2E |
Code ReviewFound 2 ULong underflow bugs in AppViewModel.kt that need to be fixed. Bug 1: Line 735 in validateLightningInvoice()The raw ULong subtraction Scenario:
This would show the user an error claiming they need billions of satoshis more to pay a small invoice. CLAUDE.md violation: "ALWAYS wrap See: bitkit-android/app/src/main/java/to/bitkit/models/USat.kt Lines 8 to 13 in 84a1241
bitkit-android/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt Lines 733 to 737 in 84a1241
Fix: Use Bug 2: Line 1125 in onScanLightning()Same issue - raw ULong subtraction bitkit-android/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt Lines 1123 to 1127 in 84a1241
Fix: Use Note: Both issues occur because |
Fixes #354
Description
This PR implement the balance validation of #354
Preview
zero-balance-scan-zero-amount-invoice.webm
zero-balance-sance-ln-amount-invoice.webm
invalid.webm
network-mismatch.webm
insufficient-savingsbalance-uniffied.webm
QA Notes