cake_wallet/lib/lightning/cw_lightning.dart

70 lines
2.1 KiB
Dart
Raw Normal View History

2024-02-08 19:45:21 +00:00
part of 'lightning.dart';
class CWLightning extends Lightning {
2024-03-01 17:55:44 +00:00
@override
String formatterLightningAmountToString({required int amount}) =>
bitcoinAmountToString(amount: amount * 100000000);
2024-02-08 19:45:21 +00:00
2024-03-01 17:55:44 +00:00
@override
double formatterLightningAmountToDouble({required int amount}) =>
bitcoinAmountToDouble(amount: amount * 100000000);
2024-02-08 19:45:21 +00:00
2024-03-01 17:55:44 +00:00
@override
2024-03-05 07:21:06 +00:00
int formatterStringDoubleToLightningAmount(String amount) =>
stringDoubleToBitcoinAmount(amount * 100000000);
2024-02-08 19:45:21 +00:00
2024-03-01 17:55:44 +00:00
WalletService createLightningWalletService(
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
return LightningWalletService(walletInfoSource, unspentCoinSource);
}
2024-02-23 17:29:11 +00:00
@override
2024-03-01 17:55:44 +00:00
List<LightningReceivePageOption> getLightningReceivePageOptions() =>
LightningReceivePageOption.all;
2024-03-05 17:51:20 +00:00
@override
ReceivePageOption getOptionInvoice() => LightningReceivePageOption.lightningInvoice;
@override
ReceivePageOption getOptionOnchain() => LightningReceivePageOption.lightningOnchain;
2024-03-06 19:21:24 +00:00
@override
2024-03-05 17:51:20 +00:00
String satsToLightningString(int sats) {
const bitcoinAmountLength = 8;
const bitcoinAmountDivider = 100000000;
const lightningAmountDivider = 1;
final bitcoinAmountFormat = NumberFormat()
..maximumFractionDigits = bitcoinAmountLength
..minimumFractionDigits = 1;
String formattedAmount = bitcoinAmountFormat.format(sats);
return formattedAmount.substring(0, formattedAmount.length - 2);
}
2024-03-06 19:21:24 +00:00
@override
2024-03-05 17:51:20 +00:00
String bitcoinAmountToLightningString({required int amount}) {
final bitcoinAmountFormat = NumberFormat()
..maximumFractionDigits = bitcoinAmountLength
..minimumFractionDigits = 1;
2024-03-06 19:21:24 +00:00
String formattedAmount =
bitcoinAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: 1));
2024-03-05 17:51:20 +00:00
return formattedAmount.substring(0, formattedAmount.length - 2);
}
2024-03-06 19:21:24 +00:00
@override
2024-03-05 17:51:20 +00:00
int bitcoinAmountToLightningAmount({required int amount}) {
return amount * 100000000;
}
2024-03-06 19:21:24 +00:00
@override
double bitcoinDoubleToLightningDouble({required double amount}) {
return amount * 100000000;
}
@override
double lightningDoubleToBitcoinDouble({required double amount}) {
return amount / 100000000;
}
2024-03-01 17:55:44 +00:00
}