diff --git a/assets/images/lightning_logo.png b/assets/images/lightning_logo.png new file mode 100644 index 000000000..af38b4ccb Binary files /dev/null and b/assets/images/lightning_logo.png differ diff --git a/assets/images/lightning_logo.svg b/assets/images/lightning_logo.svg new file mode 100644 index 000000000..6fbc51ef4 --- /dev/null +++ b/assets/images/lightning_logo.svg @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/cw_bitcoin/lib/electrum_wallet_snapshot.dart b/cw_bitcoin/lib/electrum_wallet_snapshot.dart index 98c3753db..e0d70f05d 100644 --- a/cw_bitcoin/lib/electrum_wallet_snapshot.dart +++ b/cw_bitcoin/lib/electrum_wallet_snapshot.dart @@ -42,7 +42,7 @@ class ElectrumWalletSnapshot { .whereType() .map((addr) => BitcoinAddressRecord.fromJSON(addr, network)) .toList(); - final balance = ElectrumBalance.fromJSON(data['balance'] as String) ?? + final balance = ElectrumBalance.fromJSON(data['balance'] as String?) ?? ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0); var regularAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0}; var changeAddressIndexByType = {SegwitAddresType.p2wpkh.toString(): 0}; diff --git a/cw_core/lib/amount_converter.dart b/cw_core/lib/amount_converter.dart index 249b87bd3..6be067d89 100644 --- a/cw_core/lib/amount_converter.dart +++ b/cw_core/lib/amount_converter.dart @@ -23,6 +23,8 @@ class AmountConverter { return _moneroAmountToDouble(amount); case CryptoCurrency.btc: return _bitcoinAmountToDouble(amount); + case CryptoCurrency.btcln: + return _lightningAmountToDouble(amount); case CryptoCurrency.bch: return _bitcoinCashAmountToDouble(amount); case CryptoCurrency.dash: @@ -83,6 +85,8 @@ class AmountConverter { case CryptoCurrency.bch: case CryptoCurrency.ltc: return _bitcoinAmountToString(amount); + case CryptoCurrency.btcln: + return _lightningAmountToString(amount); case CryptoCurrency.xhv: case CryptoCurrency.xag: case CryptoCurrency.xau: @@ -119,9 +123,17 @@ class AmountConverter { _bitcoinAmountFormat.format( cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider)); + static String _lightningAmountToString(int amount) { + String formattedAmount = _bitcoinAmountFormat.format(amount); + return formattedAmount.substring(0, formattedAmount.length - 2); + } + static double _bitcoinAmountToDouble(int amount) => cryptoAmountToDouble(amount: amount, divider: _bitcoinAmountDivider); + static double _lightningAmountToDouble(int amount) => + cryptoAmountToDouble(amount: amount, divider: 1); + static int _doubleToBitcoinAmount(double amount) => (amount * _bitcoinAmountDivider).toInt(); diff --git a/cw_core/lib/crypto_currency.dart b/cw_core/lib/crypto_currency.dart index 93684ec0f..023d64ed4 100644 --- a/cw_core/lib/crypto_currency.dart +++ b/cw_core/lib/crypto_currency.dart @@ -186,7 +186,7 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen static const scrt = CryptoCurrency(title: 'SCRT', fullName: 'Secret Network', raw: 59, name: 'scrt', iconPath: 'assets/images/scrt_icon.png', decimals: 6); static const uni = CryptoCurrency(title: 'UNI', tag: 'ETH', fullName: 'Uniswap', raw: 60, name: 'uni', iconPath: 'assets/images/uni_icon.png', decimals: 18); static const stx = CryptoCurrency(title: 'STX', fullName: 'Stacks', raw: 61, name: 'stx', iconPath: 'assets/images/stx_icon.png', decimals: 8); - static const btcln = CryptoCurrency(title: 'BTC', tag: 'LN', fullName: 'Bitcoin Lightning Network', raw: 62, name: 'btcln', iconPath: 'assets/images/btc.png', decimals: 8); + static const btcln = CryptoCurrency(title: 'Sats', tag: 'LN', fullName: 'Bitcoin Lightning Network', raw: 62, name: 'btcln', iconPath: 'assets/images/lightning_logo.png', decimals: 8); static const shib = CryptoCurrency(title: 'SHIB', tag: 'ETH', fullName: 'Shiba Inu', raw: 63, name: 'shib', iconPath: 'assets/images/shib_icon.png', decimals: 18); static const aave = CryptoCurrency(title: 'AAVE', tag: 'ETH', fullName: 'Aave', raw: 64, name: 'aave', iconPath: 'assets/images/aave_icon.png', decimals: 18); static const arb = CryptoCurrency(title: 'ARB', fullName: 'Arbitrum', raw: 65, name: 'arb', iconPath: 'assets/images/arb_icon.png', decimals: 18); @@ -216,7 +216,7 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen static const kaspa = CryptoCurrency(title: 'KAS', fullName: 'Kaspa', raw: 89, name: 'kas', iconPath: 'assets/images/kaspa_icon.png', decimals: 8); static const digibyte = CryptoCurrency(title: 'DGB', fullName: 'DigiByte', raw: 90, name: 'dgb', iconPath: 'assets/images/digibyte.png', decimals: 8); static const usdtSol = CryptoCurrency(title: 'USDT', tag: 'SOL', fullName: 'USDT Tether', raw: 90, name: 'usdtsol', iconPath: 'assets/images/usdt_icon.png', decimals: 6); - static const satoshis = CryptoCurrency(title: 'Sats', fullName: 'Satoshis', raw: 91, name: 'sats', iconPath: 'assets/images/btc.png', decimals: 0); + static const satoshis = CryptoCurrency(title: 'Sats', fullName: 'Satoshis', raw: 91, name: 'sats', iconPath: 'assets/images/lightning_logo.png', decimals: 0); diff --git a/cw_core/lib/wallet_type.dart b/cw_core/lib/wallet_type.dart index edecc6d81..1774ad051 100644 --- a/cw_core/lib/wallet_type.dart +++ b/cw_core/lib/wallet_type.dart @@ -194,7 +194,7 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) { case WalletType.polygon: return CryptoCurrency.maticpoly; case WalletType.lightning: - return CryptoCurrency.btc; + return CryptoCurrency.btcln; case WalletType.solana: return CryptoCurrency.sol; default: diff --git a/cw_lightning/lib/lightning_wallet.dart b/cw_lightning/lib/lightning_wallet.dart index e42b44e51..9141512aa 100644 --- a/cw_lightning/lib/lightning_wallet.dart +++ b/cw_lightning/lib/lightning_wallet.dart @@ -84,7 +84,7 @@ abstract class LightningWalletBase _password = password, _isTransactionUpdating = false, balance = ObservableMap.of({ - CryptoCurrency.btc: + CryptoCurrency.btcln: initialBalance ?? const LightningBalance(confirmed: 0, unconfirmed: 0, frozen: 0) }), super(walletInfo) { @@ -207,7 +207,7 @@ abstract class LightningWalletBase sdk.nodeStateStream.listen((event) { if (event == null) return; - balance[CryptoCurrency.btc] = LightningBalance( + balance[CryptoCurrency.btcln] = LightningBalance( confirmed: event.maxPayableMsat ~/ 1000, unconfirmed: event.maxReceivableMsat ~/ 1000, frozen: 0, diff --git a/lib/core/address_validator.dart b/lib/core/address_validator.dart index 853762a1c..9cfc01ec3 100644 --- a/lib/core/address_validator.dart +++ b/lib/core/address_validator.dart @@ -270,6 +270,7 @@ class AddressValidator extends TextValidator { '|([^0-9a-zA-Z]|^)8[0-9a-zA-Z]{94}([^0-9a-zA-Z]|\$)' '|([^0-9a-zA-Z]|^)[0-9a-zA-Z]{106}([^0-9a-zA-Z]|\$)'; case CryptoCurrency.btc: + case CryptoCurrency.btcln: return '([^0-9a-zA-Z]|^)${P2pkhAddress.regex.pattern}|\$)' '([^0-9a-zA-Z]|^)${P2shAddress.regex.pattern}|\$)' '([^0-9a-zA-Z]|^)${P2wpkhAddress.regex.pattern}|\$)' diff --git a/lib/view_model/lightning_view_model.dart b/lib/view_model/lightning_view_model.dart index 65045e7fc..3370a0d0f 100644 --- a/lib/view_model/lightning_view_model.dart +++ b/lib/view_model/lightning_view_model.dart @@ -39,13 +39,14 @@ abstract class LightningViewModelBase with Store { Future> invoiceLimitsSats() async { final sdk = await BreezSDK(); - final req = ReceivePaymentRequest( - amountMsat: 3000 * 1000,// 3000 sats + 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 + int max = 1000000000 * 1000 * 10; // 10 BTC return [min.toString(), max.toString()]; } }