fix min sats being stuck at 2500

This commit is contained in:
Matthew Fosse 2024-03-04 15:37:22 -08:00
parent bfd35e493d
commit e32203945a
2 changed files with 6 additions and 17 deletions

View file

@ -112,9 +112,9 @@ abstract class LightningInvoicePageViewModelBase with Store {
}
Future<void> _fetchLimits() async {
List<String> limits = await lightningViewModel.invoiceLimitsSats();
minimum = double.parse(limits[0]);
maximum = double.parse(limits[1]);
List<int> limits = await lightningViewModel.invoiceSoftLimitsSats();
minimum = limits[0].toDouble();
maximum = limits[1].toDouble();
}
@action

View file

@ -37,19 +37,6 @@ abstract class LightningViewModelBase with Store {
return res.lnInvoice.bolt11;
}
Future<List<String>> 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<List<int>> 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];
}