From 8633eb6a70130347231cf1f92fe86f83c7018166 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Fri, 1 Mar 2024 08:49:24 -0800 Subject: [PATCH] save before adding translations --- .../receive/lightning_invoice_page.dart | 19 ++++++++++++++++--- lib/view_model/lightning_view_model.dart | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/src/screens/receive/lightning_invoice_page.dart b/lib/src/screens/receive/lightning_invoice_page.dart index e67112120..00e696100 100644 --- a/lib/src/screens/receive/lightning_invoice_page.dart +++ b/lib/src/screens/receive/lightning_invoice_page.dart @@ -171,11 +171,24 @@ class LightningInvoicePage extends BasePage { child: Container(child: Center(child: CircularProgressIndicator()))); } - String min = (snapshot.data as List)[0]; - min = satsToLightningString(double.parse(min)); + late String min; + bool zeroBalance = false; + if (zeroBalance) { + min = (snapshot.data as List)[0]; + min = satsToLightningString(double.parse(min)); + min = S.of(context).lightning_invoice_min(min); + } else { + min = (snapshot.data as List)[0]; + String max = (snapshot.data as List)[1]; + min = satsToLightningString(double.parse(min)); + max = satsToLightningString(double.parse(max)); + // min = S.of(context).lightning_invoice_min_max(min, max); + min = "$min $max"; + } + return Expanded( child: Text( - S.of(context).lightning_invoice_min(min), + min, maxLines: 4, style: TextStyle( fontSize: 14, diff --git a/lib/view_model/lightning_view_model.dart b/lib/view_model/lightning_view_model.dart index 3370a0d0f..26b65d89e 100644 --- a/lib/view_model/lightning_view_model.dart +++ b/lib/view_model/lightning_view_model.dart @@ -49,4 +49,23 @@ abstract class LightningViewModelBase with Store { int max = 1000000000 * 1000 * 10; // 10 BTC return [min.toString(), max.toString()]; } + + Future> invoiceSoftLimitsSats() async { + final sdk = await BreezSDK(); + ReceivePaymentRequest? req = null; + req = ReceivePaymentRequest( + amountMsat: 10000 * 1000, // 10000 sats + description: "limits", + ); + final res = await sdk.receivePayment(req: req); + int min = (res.openingFeeMsat ?? (2500 * 1000)) ~/ 1000; + + int max = 1000000000 * 1000 * 10; // 10 BTC + + try { + final nodeState = (await sdk.nodeInfo())!; + max = nodeState.inboundLiquidityMsats ~/ 1000; + } catch (_) {} + return [min.toString(), max.toString()]; + } }