mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-10 08:33:54 +01:00
Handle network errors, improve Lightning setup, and add deposit events (#3127)
* fix: send all for lightning * fix: adjust crypto amount parsing logic for send page outputs * feat: add event handling for deposit transactions in Bitcoin and Lightning wallets - Introduced `onCreateDepositTransactionEvent` and `onUpdateDepositTransactionEvent` callbacks to manage deposit transaction updates. - Updated event listener logic to handle unclaimed and claimed deposit events. - Added support for processing deposit transaction info with `ElectrumTransactionInfo`. * fix: handle network errors on username validation and improve Lightning address setup - Added network error handling for username validation with a fallback error. - Enhanced Lightning address setup logic with error handling and a fail-safe mechanism to disable Lightning usage if the setup fails. * fix: enhance error handling for Lightning and update validation patterns * fix: remove redundant raw string mark from amount validation pattern * fix: normalize crypto amount input by replacing commas with dots
This commit is contained in:
@@ -65,7 +65,7 @@ class SymbolsAmountValidator extends TextValidator {
|
||||
maxLength: 0,
|
||||
);
|
||||
|
||||
static String _pattern() => '^([0-9]+([.\,][0-9]+)?|[.\,][0-9]+)\$';
|
||||
static String _pattern() => r'^(?:\d+(?:[.\,]\d+)?|[.\,]\d+)$';
|
||||
}
|
||||
|
||||
class DecimalAmountValidator extends TextValidator {
|
||||
|
||||
@@ -12,7 +12,8 @@ class LNUrlPayRecord {
|
||||
final String name;
|
||||
final String address;
|
||||
|
||||
static Future<String?> checkWellKnownUsername(String username, CryptoCurrency currency) async {
|
||||
static Future<String?> checkWellKnownUsername(String username, CryptoCurrency currency,
|
||||
{bool allowRethrow = false}) async {
|
||||
if (![CryptoCurrency.btc, CryptoCurrency.btcln].contains(currency)) return null;
|
||||
|
||||
// split the string by the @ symbol:
|
||||
@@ -40,6 +41,7 @@ class LNUrlPayRecord {
|
||||
return LNURL.encode(expectedUrl);
|
||||
}
|
||||
} catch (e) {
|
||||
if (allowRethrow) rethrow;
|
||||
printV("error checking well-known username: $e");
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -691,12 +691,15 @@ class _NewSendPageState extends State<NewSendPage> {
|
||||
void _handleSend() async {
|
||||
//TODO refactor this action. code was copied over from old ui. i don't like it.
|
||||
|
||||
for(int i=0; i<widget.sendViewModel.outputs.length; i++) {
|
||||
if(i < _amountControllers.length) {
|
||||
if(_fiatInputMode) {
|
||||
for (var i = 0; i < widget.sendViewModel.outputs.length; i++) {
|
||||
if (i < _amountControllers.length && !widget.sendViewModel.outputs[i].sendAll) {
|
||||
if (_fiatInputMode) {
|
||||
widget.sendViewModel.outputs[i].setFiatAmount(_amountControllers[i].text);
|
||||
} else {
|
||||
widget.sendViewModel.outputs[i].cryptoAmount = _amountControllers[i].text;
|
||||
final amount = widget.sendViewModel.amountParsingProxy.getCanonicalCryptoAmount(
|
||||
_amountControllers[i].text.replaceAll(",", "."),
|
||||
widget.sendViewModel.selectedCryptoCurrency);
|
||||
widget.sendViewModel.outputs[i].setCryptoAmount(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,15 @@ class LightningUsernameBloc extends Bloc<LightningUsernameEvent, LightningUserna
|
||||
return UsernameError(S.current.already_your_username, isInfo: true);
|
||||
}
|
||||
|
||||
if ((await LNUrlPayRecord.checkWellKnownUsername(
|
||||
"${username}${usernameSuffix}", CryptoCurrency.btc)) !=
|
||||
null) {
|
||||
return UsernameError(S.current.username_not_available);
|
||||
try {
|
||||
if ((await LNUrlPayRecord.checkWellKnownUsername(
|
||||
"${username}${usernameSuffix}", CryptoCurrency.btc,
|
||||
allowRethrow: true)) !=
|
||||
null) {
|
||||
return UsernameError(S.current.username_not_available);
|
||||
}
|
||||
} catch (e) {
|
||||
return UsernameError(S.current.username_check_your_network);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class NewSendAmountInput extends StatefulWidget {
|
||||
const NewSendAmountInput(
|
||||
@@ -66,7 +65,7 @@ class _NewSendAmountInputState extends State<NewSendAmountInput> {
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(signed: false, decimal: true),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*$'))
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d*[.,]?\d*$'))
|
||||
],
|
||||
onChanged: state.didChange,
|
||||
controller: widget.amountController,
|
||||
|
||||
@@ -301,7 +301,8 @@ class ExceptionHandler {
|
||||
"_QueuedFuture.execute (package:universal_ble/src/queue.dart:65)",
|
||||
"reown_core/relay_client/websocket/websocket_handler.dart",
|
||||
"Image upload failed due to loss of GPU access",
|
||||
'transport error',
|
||||
"transport error",
|
||||
"SdkError.sparkError(field0: Operator RPC error: Connection error: status: Unavailable, message: \"dns error\", details: []"
|
||||
];
|
||||
|
||||
static Future<void> _addDeviceInfo(File file) async {
|
||||
|
||||
Reference in New Issue
Block a user