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
|
|
|
|
WalletCredentials createLightningRestoreWalletFromSeedCredentials(
|
|
|
|
{required String name, required String mnemonic, required String password}) =>
|
|
|
|
BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password);
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createLightningRestoreWalletFromWIFCredentials(
|
|
|
|
{required String name,
|
|
|
|
required String password,
|
|
|
|
required String wif,
|
|
|
|
WalletInfo? walletInfo}) =>
|
|
|
|
BitcoinRestoreWalletFromWIFCredentials(
|
|
|
|
name: name, password: password, wif: wif, walletInfo: walletInfo);
|
|
|
|
|
|
|
|
@override
|
|
|
|
WalletCredentials createLightningNewWalletCredentials(
|
|
|
|
{required String name, WalletInfo? walletInfo}) =>
|
|
|
|
BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Object createLightningTransactionCredentials(List<Output> outputs,
|
|
|
|
{required TransactionPriority priority, int? feeRate}) =>
|
|
|
|
BitcoinTransactionCredentials(
|
|
|
|
outputs
|
|
|
|
.map((out) => OutputInfo(
|
|
|
|
fiatAmount: out.fiatAmount,
|
|
|
|
cryptoAmount: out.cryptoAmount,
|
|
|
|
address: out.address,
|
|
|
|
note: out.note,
|
|
|
|
sendAll: out.sendAll,
|
|
|
|
extractedAddress: out.extractedAddress,
|
|
|
|
isParsedAddress: out.isParsedAddress,
|
|
|
|
formattedCryptoAmount: out.formattedCryptoAmount))
|
|
|
|
.toList(),
|
|
|
|
priority: priority as BitcoinTransactionPriority,
|
|
|
|
feeRate: feeRate);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Object createLightningTransactionCredentialsRaw(List<OutputInfo> outputs,
|
|
|
|
{TransactionPriority? priority, required int feeRate}) =>
|
|
|
|
BitcoinTransactionCredentials(outputs,
|
|
|
|
priority: priority != null ? priority as BitcoinTransactionPriority : null,
|
|
|
|
feeRate: feeRate);
|
2024-02-08 19:45:21 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
String bitcoinAmountToLightningString({required int amount}) {
|
|
|
|
final bitcoinAmountFormat = NumberFormat()
|
|
|
|
..maximumFractionDigits = bitcoinAmountLength
|
|
|
|
..minimumFractionDigits = 1;
|
|
|
|
String formattedAmount = bitcoinAmountFormat
|
|
|
|
.format(cryptoAmountToDouble(amount: amount, divider: 1));
|
|
|
|
return formattedAmount.substring(0, formattedAmount.length - 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
int bitcoinAmountToLightningAmount({required int amount}) {
|
|
|
|
return amount * 100000000;
|
|
|
|
}
|
2024-03-01 17:55:44 +00:00
|
|
|
}
|