From e32203945a2ee702b5392784c1dc3c79828c4c2f Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Mon, 4 Mar 2024 15:37:22 -0800 Subject: [PATCH] fix min sats being stuck at 2500 --- .../lightning_invoice_page_view_model.dart | 6 +++--- lib/view_model/lightning_view_model.dart | 17 +++-------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/view_model/lightning_invoice_page_view_model.dart b/lib/view_model/lightning_invoice_page_view_model.dart index 29cf5e516..7cb8cf139 100644 --- a/lib/view_model/lightning_invoice_page_view_model.dart +++ b/lib/view_model/lightning_invoice_page_view_model.dart @@ -112,9 +112,9 @@ abstract class LightningInvoicePageViewModelBase with Store { } Future _fetchLimits() async { - List limits = await lightningViewModel.invoiceLimitsSats(); - minimum = double.parse(limits[0]); - maximum = double.parse(limits[1]); + List limits = await lightningViewModel.invoiceSoftLimitsSats(); + minimum = limits[0].toDouble(); + maximum = limits[1].toDouble(); } @action diff --git a/lib/view_model/lightning_view_model.dart b/lib/view_model/lightning_view_model.dart index 59a90b7da..d1dae5c4e 100644 --- a/lib/view_model/lightning_view_model.dart +++ b/lib/view_model/lightning_view_model.dart @@ -37,19 +37,6 @@ abstract class LightningViewModelBase with Store { return res.lnInvoice.bolt11; } - Future> invoiceLimitsSats() 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 - return [min.toString(), max.toString()]; - } - Future> invoiceSoftLimitsSats() async { final sdk = await BreezSDK(); ReceivePaymentRequest? req = null; @@ -59,7 +46,6 @@ abstract class LightningViewModelBase with Store { ); final res = await sdk.receivePayment(req: req); int min = (res.openingFeeMsat ?? (2500 * 1000)) ~/ 1000; - int max = 1000000000 * 1000 * 10; // 10 BTC int balance = 0; @@ -68,6 +54,9 @@ abstract class LightningViewModelBase with Store { final nodeState = (await sdk.nodeInfo())!; max = nodeState.inboundLiquidityMsats ~/ 1000; balance = nodeState.channelsBalanceMsat ~/ 1000; + if (balance > 0) { + min = 0; + } } catch (_) {} return [min, max, balance]; }