Skip to content
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

Apply mandatory payment status and lnurlWithdraw changes #630

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 37 additions & 45 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
PODS:
- breez_sdk (0.1.4):
- breez_sdk/breez_sdkFFI (= 0.1.4)
- breez_sdkFFI
- breez_sdk (0.1.9):
- Flutter
- breez_sdk/breez_sdkFFI (0.1.4):
- breez_sdkFFI
- Flutter
- breez_sdkFFI (0.1.4)
- clipboard_watcher (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- Firebase/CoreOnly (10.12.0):
- FirebaseCore (= 10.12.0)
- Firebase/DynamicLinks (10.12.0):
- Firebase/CoreOnly (10.15.0):
- FirebaseCore (= 10.15.0)
- Firebase/DynamicLinks (10.15.0):
- Firebase/CoreOnly
- FirebaseDynamicLinks (~> 10.12.0)
- Firebase/Messaging (10.12.0):
- FirebaseDynamicLinks (~> 10.15.0)
- Firebase/Messaging (10.15.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.12.0)
- firebase_core (2.15.0):
- Firebase/CoreOnly (= 10.12.0)
- FirebaseMessaging (~> 10.15.0)
- firebase_core (2.16.0):
- Firebase/CoreOnly (= 10.15.0)
- Flutter
- firebase_dynamic_links (5.3.4):
- Firebase/DynamicLinks (= 10.12.0)
- firebase_dynamic_links (5.3.6):
- Firebase/DynamicLinks (= 10.15.0)
- firebase_core
- Flutter
- firebase_messaging (14.6.5):
- Firebase/Messaging (= 10.12.0)
- firebase_messaging (14.6.8):
- Firebase/Messaging (= 10.15.0)
- firebase_core
- Flutter
- FirebaseCore (10.12.0):
- FirebaseCore (10.15.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreInternal (10.13.0):
- FirebaseCoreInternal (10.15.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseDynamicLinks (10.12.0):
- FirebaseDynamicLinks (10.15.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (10.13.0):
- FirebaseInstallations (10.15.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (10.12.0):
- FirebaseMessaging (10.15.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.2)
Expand Down Expand Up @@ -158,18 +152,18 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqlite3 (3.41.2):
- sqlite3/common (= 3.41.2)
- sqlite3/common (3.41.2)
- sqlite3/fts5 (3.41.2):
- sqlite3 (3.43.1):
- sqlite3/common (= 3.43.1)
- sqlite3/common (3.43.1)
- sqlite3/fts5 (3.43.1):
- sqlite3/common
- sqlite3/perf-threadsafe (3.41.2):
- sqlite3/perf-threadsafe (3.43.1):
- sqlite3/common
- sqlite3/rtree (3.41.2):
- sqlite3/rtree (3.43.1):
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
- sqlite3 (~> 3.41.2)
- sqlite3 (~> 3.43.1)
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
Expand Down Expand Up @@ -210,7 +204,6 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- breez_sdkFFI
- Firebase
- FirebaseCore
- FirebaseCoreInternal
Expand Down Expand Up @@ -287,19 +280,18 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/workmanager/ios"

SPEC CHECKSUMS:
breez_sdk: ef1b25b92c62ff061239b98f86784e25608a7c1f
breez_sdkFFI: 8ad47f4cfec4c3f26ece06a5ea60e03fa4258669
breez_sdk: 233b05873a9e87762e4da7f12eb7a91cf2caff0b
clipboard_watcher: 86fb70421aca6f4944e0591a8292605da7784666
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
Firebase: 07150e75d142fb9399f6777fa56a187b17f833a0
firebase_core: e477125798fc37cd4ab43ca6a8536bf7e0929c00
firebase_dynamic_links: d85cf455646322fd101c8a5a5942c3d47132fe80
firebase_messaging: 334d68c3a36b6d4d5cd91e4f42509e0d4ae49828
FirebaseCore: f86a1394906b97ac445ae49c92552a9425831bed
FirebaseCoreInternal: b342e37cd4f5b4454ec34308f073420e7920858e
FirebaseDynamicLinks: 1a387da899779e5ef34f4d6f8bdba882f90d0e67
FirebaseInstallations: b28af1b9f997f1a799efe818c94695a3728c352f
FirebaseMessaging: bb2c4f6422a753038fe137d90ae7c1af57251316
Firebase: 66043bd4579e5b73811f96829c694c7af8d67435
firebase_core: 77172d0a9d8d19d07606e24406e4c2fc14d3265b
firebase_dynamic_links: 27625ac999a9353d6e323c07db85c3b55c5c6839
firebase_messaging: 6aff54d420b7ce7080c26dd131b08bc632666852
FirebaseCore: 2cec518b43635f96afe7ac3a9c513e47558abd2e
FirebaseCoreInternal: 2f4bee5ed00301b5e56da0849268797a2dd31fb4
FirebaseDynamicLinks: 206d4ed3efd2b722822598017f3980d9fda89815
FirebaseInstallations: cae95cab0f965ce05b805189de1d4c70b11c76fb
FirebaseMessaging: 0c0ae1eb722ef0c07f7801e5ded8dccd1357d6d4
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_fgbg: 31c0d1140a131daea2d342121808f6aa0dcd879d
flutter_fimber: ec011dfb08d7cbfa16ab6bad8450b99574e6f6a4
Expand Down Expand Up @@ -329,8 +321,8 @@ SPEC CHECKSUMS:
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqlite3: fd89671d969f3e73efe503ce203e28b016b58f68
sqlite3_flutter_libs: 04ba0d14a04335a2fbf9a331e8664f401fbccdd5
sqlite3: e0a0623a33a20a47cb5921552aebc6e9e437dc91
sqlite3_flutter_libs: 0d61e18fab1bed977dbd2d2fc76a726044ca00e7
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
Expand Down
5 changes: 3 additions & 2 deletions lib/background/payment_hash_poller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class PaymentHashPoller {
);
for (var payment in paymentList) {
final detailsData = payment.details.data;
final isPaymentReceived =
!payment.pending && detailsData is LnPaymentDetails && detailsData.paymentHash == paymentHash;
final isPaymentReceived = payment.status == PaymentStatus.Complete &&
detailsData is LnPaymentDetails &&
detailsData.paymentHash == paymentHash;
if (isPaymentReceived) {
print("Payment received! Stop polling.");
timer.cancel();
Expand Down
2 changes: 1 addition & 1 deletion lib/bloc/account/account_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AccountBloc extends Cubit<AccountState> with HydratedMixin {
});
}

Future<sdk.LnUrlCallbackStatus> lnurlWithdraw({
Future<sdk.LnUrlWithdrawResult> lnurlWithdraw({
required int amountSats,
required sdk.LnUrlWithdrawRequestData reqData,
String? description,
Expand Down
6 changes: 3 additions & 3 deletions lib/models/payment_minutiae.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentMinutiae {
final int amountSat;
final bool hasMetadata;
final bool isKeySend;
final bool isPending;
final PaymentStatus status;

const PaymentMinutiae({
required this.id,
Expand All @@ -49,7 +49,7 @@ class PaymentMinutiae {
required this.amountSat,
required this.hasMetadata,
required this.isKeySend,
required this.isPending,
required this.status,
});

factory PaymentMinutiae.fromPayment(Payment payment, BreezTranslations texts) {
Expand All @@ -72,7 +72,7 @@ class PaymentMinutiae {
amountSat: factory._amountSat(),
hasMetadata: factory._hasMetadata(),
isKeySend: factory._isKeySend(),
isPending: payment.pending,
status: payment.status,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:c_breez/routes/home/widgets/payments_list/dialog/tx_widget.dart';
Expand All @@ -16,7 +17,7 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget {
final themeData = Theme.of(context);
final texts = context.texts();

if (!paymentMinutiae.isPending) {
if (paymentMinutiae.status == PaymentStatus.Complete) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:c_breez/routes/home/widgets/payments_list/dialog/closed_channel_payment_details.dart';
Expand All @@ -19,7 +20,7 @@ class PaymentDetailsDialogClosedChannelDialog extends StatelessWidget {
return AlertDialog(
titlePadding: const EdgeInsets.fromLTRB(24, 22, 0, 16),
title: Text(
paymentMinutiae.isPending
paymentMinutiae.status == PaymentStatus.Pending
? texts.payment_details_dialog_closed_channel_title_pending
: texts.payment_details_dialog_closed_channel_title,
style: themeData.dialogTheme.titleTextStyle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:flutter/material.dart';
Expand All @@ -18,7 +19,7 @@ class PaymentDetailsDialogExpiration extends StatelessWidget {
final texts = context.texts();
final themeData = Theme.of(context);

if (!paymentMinutiae.isPending) {
if (paymentMinutiae.status == PaymentStatus.Complete) {
return Container();
}

Expand Down
17 changes: 9 additions & 8 deletions lib/routes/home/widgets/payments_list/payment_item_amount.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class PaymentItemAmount extends StatelessWidget {
);

return Column(
mainAxisAlignment: _paymentMinutiae.feeMilliSat == 0 || _paymentMinutiae.isPending
? MainAxisAlignment.center
: MainAxisAlignment.spaceAround,
mainAxisAlignment:
_paymentMinutiae.feeMilliSat == 0 || _paymentMinutiae.status == PaymentStatus.Pending
? MainAxisAlignment.center
: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
Expand All @@ -59,7 +60,7 @@ class PaymentItemAmount extends StatelessWidget {
: texts.wallet_dashboard_payment_item_balance_negative(amount),
style: themeData.paymentItemAmountTextStyle,
),
(fee == 0 || _paymentMinutiae.isPending)
(fee == 0 || _paymentMinutiae.status == PaymentStatus.Pending)
? const SizedBox()
: Text(
hideBalance
Expand Down Expand Up @@ -102,7 +103,7 @@ void main() async {
feeMsat: 0,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -128,7 +129,7 @@ void main() async {
feeMsat: 1234,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: true,
status: PaymentStatus.Pending,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -154,7 +155,7 @@ void main() async {
feeMsat: 1234,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -180,7 +181,7 @@ void main() async {
feeMsat: 1234,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentItemSubtitle extends StatelessWidget {
BreezDateUtils.formatTimelineRelative(_paymentMinutiae.paymentTime),
style: subtitleTextStyle,
),
_paymentMinutiae.isPending
_paymentMinutiae.status == PaymentStatus.Pending
? Text(
texts.wallet_dashboard_payment_item_balance_pending_suffix,
style: subtitleTextStyle.copyWith(
Expand All @@ -55,7 +55,7 @@ void main() {
feeMsat: 1234,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -81,7 +81,7 @@ void main() {
feeMsat: 1234,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: true,
status: PaymentStatus.Pending,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/home/widgets/payments_list/payment_item_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void main() {
feeMsat: 0,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -62,7 +62,7 @@ void main() {
feeMsat: 0,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "A long title\nwith a new line",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -88,7 +88,7 @@ void main() {
feeMsat: 0,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "A short title",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/home/widgets/payments_list/payments_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void main() async {
feeMsat: 0,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "A title",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -88,7 +88,7 @@ void main() async {
feeMsat: 12,
paymentTime: 1661791810,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "A title",
details: PaymentDetails.ln(
data: LnPaymentDetails(
Expand All @@ -110,7 +110,7 @@ void main() async {
feeMsat: 3456,
paymentTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
amountMsat: 4321000,
pending: false,
status: PaymentStatus.Complete,
description: "A title",
details: const PaymentDetails.ln(
data: LnPaymentDetails(
Expand Down
12 changes: 7 additions & 5 deletions lib/routes/lnurl/withdraw/lnurl_withdraw_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,16 @@ class _LNURLWithdrawDialogState extends State<LNURLWithdrawDialog> with SingleTi
amountSats: widget.amountSats,
description: description,
);
if (resp is sdk.LnUrlCallbackStatus_Ok) {
_log.v("LNURL withdraw success");
if (resp is sdk.LnUrlWithdrawSuccessData) {
final paymentHash = (resp as sdk.LnUrlWithdrawSuccessData).invoice.paymentHash;
_log.v("LNURL withdraw success for $paymentHash");
return const LNURLPageResult(protocol: LnUrlProtocol.Withdraw);
} else if (resp is sdk.LnUrlCallbackStatus_ErrorStatus) {
_log.v("LNURL withdraw failed: ${resp.data.reason}");
} else if (resp is sdk.LnUrlErrorData) {
final reason = (resp as sdk.LnUrlErrorData).reason;
_log.v("LNURL withdraw failed: $reason");
return LNURLPageResult(
protocol: LnUrlProtocol.Withdraw,
error: resp.data.reason,
error: reason,
);
} else {
_log.w("Unknown response from lnurlWithdraw: $resp");
Expand Down
Loading