Skip to content

Commit

Permalink
Trigger send to BTC address flow when camera reads a BTC address
Browse files Browse the repository at this point in the history
  • Loading branch information
ademar111190 committed Oct 9, 2023
1 parent 213ed2c commit 296cc9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/bloc/input/input_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class InputBloc extends Cubit<InputState> {
parsedInput is InputType_LnUrlWithdraw ||
parsedInput is InputType_LnUrlAuth ||
parsedInput is InputType_LnUrlError ||
parsedInput is InputType_NodeId) {
parsedInput is InputType_NodeId ||
parsedInput is InputType_BitcoinAddress) {
return InputState(inputData: parsedInput);
} else {
return InputState(isLoading: false);
Expand Down Expand Up @@ -145,6 +146,10 @@ class InputBloc extends Cubit<InputState> {
_log.info("nodeId: ${parsedInput.nodeId}");
} else if (parsedInput is InputType_Url) {
_log.info("url: ${parsedInput.url}");
} else if (parsedInput is InputType_BitcoinAddress) {
_log.info("address: ${parsedInput.address.address}");
} else {
_log.info("Other input type");
}
}

Expand Down
9 changes: 8 additions & 1 deletion lib/handlers/input_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import 'package:c_breez/widgets/flushbar.dart';
import 'package:c_breez/widgets/loader.dart';
import 'package:c_breez/widgets/payment_dialogs/payment_request_dialog.dart';
import 'package:c_breez/widgets/route.dart';
import 'package:logging/logging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:logging/logging.dart';

final _log = Logger("InputHandler");

Expand Down Expand Up @@ -114,6 +114,8 @@ class InputHandler extends Handler {
return handleLNURL(context, firstPaymentItemKey, parsedInput.data);
} else if (parsedInput is InputType_NodeId) {
return handleNodeID(context, parsedInput.nodeId);
} else if (parsedInput is InputType_BitcoinAddress) {
return handleBitcoinAddress(context, parsedInput.address);
}
}

Expand Down Expand Up @@ -143,6 +145,11 @@ class InputHandler extends Handler {
);
}

Future handleBitcoinAddress(BuildContext context, BitcoinAddressData address) async {
_log.fine("handle bitcoin address $address");
return await Navigator.of(context).pushNamed("/reverse_swap", arguments: address);
}

void _setLoading(bool visible) {
if (visible && _loaderRoute == null) {
final context = contextProvider?.getBuildContext();
Expand Down

0 comments on commit 296cc9a

Please sign in to comment.