diff --git a/.github/workflows/pr_test_build.yml b/.github/workflows/pr_test_build.yml
index 99a45287f..af6c947f5 100644
--- a/.github/workflows/pr_test_build.yml
+++ b/.github/workflows/pr_test_build.yml
@@ -158,6 +158,9 @@ jobs:
echo "const walletConnectProjectId = '${{ secrets.WALLET_CONNECT_PROJECT_ID }}';" >> lib/.secrets.g.dart
echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> lib/.secrets.g.dart
echo "const polygonScanApiKey = '${{ secrets.POLYGON_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
+ echo "const breezApiKey = '${{ secrets.BREEZ_API_KEY }}';" >> cw_lightning/lib/.secrets.g.dart
+ echo "const greenlightCert = '${{ secrets.GREENLIGHT_CERTIFICATE }}';" >> cw_lightning/lib/.secrets.g.dart
+ echo "const greenlightKey = '${{ secrets.GREENLIGHT_KEY }}';" >> cw_lightning/lib/.secrets.g.dart
echo "const ankrApiKey = '${{ secrets.ANKR_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
echo "const testCakePayApiKey = '${{ secrets.TEST_CAKE_PAY_API_KEY }}';" >> lib/.secrets.g.dart
echo "const cakePayApiKey = '${{ secrets.CAKE_PAY_API_KEY }}';" >> lib/.secrets.g.dart
diff --git a/.gitignore b/.gitignore
index 77441e66f..f4d8b2543 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,6 +128,7 @@ cw_haven/android/.externalNativeBuild/
cw_haven/android/.cxx/
lib/bitcoin/bitcoin.dart
+lib/lightning/lightning.dart
lib/monero/monero.dart
lib/haven/haven.dart
lib/ethereum/ethereum.dart
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 5e27aeb9e..263c47105 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -23,6 +23,7 @@ if (flutterVersionName == null) {
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
+apply plugin: 'kotlinx-serialization'
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
diff --git a/android/app/src/main/AndroidManifestBase.xml b/android/app/src/main/AndroidManifestBase.xml
index b03c8a925..fa15e7b70 100644
--- a/android/app/src/main/AndroidManifestBase.xml
+++ b/android/app/src/main/AndroidManifestBase.xml
@@ -9,6 +9,8 @@
+
+
@@ -69,6 +71,9 @@
+
+
+
@@ -115,6 +120,24 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
+
+
+
+
+
+
+
+
diff --git a/android/build.gradle b/android/build.gradle
index aa9f5005d..6a56a8f70 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -9,6 +9,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.gms:google-services:4.3.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
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/assets/images/warning.png b/assets/images/warning.png
new file mode 100644
index 000000000..179eb4b5a
Binary files /dev/null and b/assets/images/warning.png differ
diff --git a/configure_cake_wallet.sh b/configure_cake_wallet.sh
index 0539221a3..36f1c2de4 100755
--- a/configure_cake_wallet.sh
+++ b/configure_cake_wallet.sh
@@ -31,5 +31,4 @@ source ./app_env.sh cakewallet
./app_config.sh
cd ../.. && flutter pub get
#flutter packages pub run tool/generate_localization.dart
-./model_generator.sh
-#cd macos && pod install
\ No newline at end of file
+./model_generator.sh
\ No newline at end of file
diff --git a/cw_bitcoin/lib/bitcoin_amount_format.dart b/cw_bitcoin/lib/bitcoin_amount_format.dart
index d5a42d984..7069c8396 100644
--- a/cw_bitcoin/lib/bitcoin_amount_format.dart
+++ b/cw_bitcoin/lib/bitcoin_amount_format.dart
@@ -3,12 +3,13 @@ import 'package:cw_core/crypto_amount_format.dart';
const bitcoinAmountLength = 8;
const bitcoinAmountDivider = 100000000;
+const lightningAmountDivider = 1;
final bitcoinAmountFormat = NumberFormat()
..maximumFractionDigits = bitcoinAmountLength
..minimumFractionDigits = 1;
-String bitcoinAmountToString({required int amount}) => bitcoinAmountFormat.format(
- cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider));
+String bitcoinAmountToString({required int amount}) =>
+ bitcoinAmountFormat.format(cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider));
double bitcoinAmountToDouble({required int amount}) =>
cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
@@ -24,3 +25,9 @@ int stringDoubleToBitcoinAmount(String amount) {
return result;
}
+
+String bitcoinAmountToLightningString({required int amount}) {
+ String formattedAmount = bitcoinAmountFormat
+ .format(cryptoAmountToDouble(amount: amount, divider: lightningAmountDivider));
+ return formattedAmount.substring(0, formattedAmount.length - 2);
+}
diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart
index db42e2356..e2cc75a85 100644
--- a/cw_bitcoin/lib/electrum_wallet.dart
+++ b/cw_bitcoin/lib/electrum_wallet.dart
@@ -73,6 +73,7 @@ abstract class ElectrumWalletBase
getAccountHDWallet(currency, networkType, seedBytes, xpub, walletInfo.derivationInfo),
syncStatus = NotConnectedSyncStatus(),
_password = password,
+ _mnemonic = mnemonic,
_feeRates = [],
_isTransactionUpdating = false,
isEnabledAutoGenerateSubaddress = true,
@@ -91,7 +92,6 @@ abstract class ElectrumWalletBase
this.unspentCoinsInfo = unspentCoinsInfo,
this.network = _getNetwork(networkType, currency),
this.isTestnet = networkType == bitcoin.testnet,
- this._mnemonic = mnemonic,
super(walletInfo) {
this.electrumClient = electrumClient ?? ElectrumClient();
this.walletInfo = walletInfo;
@@ -1138,7 +1138,7 @@ abstract class ElectrumWalletBase
}
@override
- Future close() async {
+ Future close({bool? switchingToSameWalletType}) async {
try {
await electrumClient.close();
} catch (_) {}
diff --git a/cw_bitcoin/lib/litecoin_wallet.dart b/cw_bitcoin/lib/litecoin_wallet.dart
index 209ddc774..f79143b2b 100644
--- a/cw_bitcoin/lib/litecoin_wallet.dart
+++ b/cw_bitcoin/lib/litecoin_wallet.dart
@@ -33,15 +33,16 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
Map? initialRegularAddressIndex,
Map? initialChangeAddressIndex,
}) : super(
- mnemonic: mnemonic,
- password: password,
- walletInfo: walletInfo,
- unspentCoinsInfo: unspentCoinsInfo,
- networkType: litecoinNetwork,
- initialAddresses: initialAddresses,
- initialBalance: initialBalance,
- seedBytes: seedBytes,
- currency: CryptoCurrency.ltc) {
+ mnemonic: mnemonic,
+ password: password,
+ walletInfo: walletInfo,
+ unspentCoinsInfo: unspentCoinsInfo,
+ networkType: litecoinNetwork,
+ initialAddresses: initialAddresses,
+ initialBalance: initialBalance,
+ seedBytes: seedBytes,
+ currency: CryptoCurrency.ltc,
+ ) {
walletAddresses = LitecoinWalletAddresses(
walletInfo,
initialAddresses: initialAddresses,
diff --git a/cw_bitcoin/pubspec.yaml b/cw_bitcoin/pubspec.yaml
index 66c5729e8..5159ac991 100644
--- a/cw_bitcoin/pubspec.yaml
+++ b/cw_bitcoin/pubspec.yaml
@@ -27,7 +27,7 @@ dependencies:
git:
url: https://github.com/cake-tech/bitbox-flutter.git
ref: Add-Support-For-OP-Return-data
- rxdart: ^0.27.5
+ rxdart: ^0.28.0
cryptography: ^2.0.5
bitcoin_base:
git:
@@ -53,7 +53,7 @@ dev_dependencies:
build_runner: ^2.4.7
build_resolvers: ^2.0.9
mobx_codegen: ^2.0.7
- hive_generator: ^1.1.3
+ hive_generator: ^2.0.1
dependency_overrides:
watcher: ^1.1.0
diff --git a/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart b/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart
index 51bd3612d..a674b1cc6 100644
--- a/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart
+++ b/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart
@@ -35,15 +35,16 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
Map? initialRegularAddressIndex,
Map? initialChangeAddressIndex,
}) : super(
- mnemonic: mnemonic,
- password: password,
- walletInfo: walletInfo,
- unspentCoinsInfo: unspentCoinsInfo,
- networkType: bitcoin.bitcoin,
- initialAddresses: initialAddresses,
- initialBalance: initialBalance,
- seedBytes: seedBytes,
- currency: CryptoCurrency.bch) {
+ mnemonic: mnemonic,
+ password: password,
+ walletInfo: walletInfo,
+ unspentCoinsInfo: unspentCoinsInfo,
+ networkType: bitcoin.bitcoin,
+ initialAddresses: initialAddresses,
+ initialBalance: initialBalance,
+ seedBytes: seedBytes,
+ currency: CryptoCurrency.bch,
+ ) {
walletAddresses = BitcoinCashWalletAddresses(
walletInfo,
initialAddresses: initialAddresses,
diff --git a/cw_bitcoin_cash/pubspec.yaml b/cw_bitcoin_cash/pubspec.yaml
index a0ce889c1..abb3b5aef 100644
--- a/cw_bitcoin_cash/pubspec.yaml
+++ b/cw_bitcoin_cash/pubspec.yaml
@@ -43,7 +43,7 @@ dev_dependencies:
sdk: flutter
build_runner: ^2.4.7
mobx_codegen: ^2.0.7
- hive_generator: ^1.1.3
+ hive_generator: ^2.0.1
dependency_overrides:
watcher: ^1.1.0
diff --git a/cw_core/lib/amount_converter.dart b/cw_core/lib/amount_converter.dart
index 1c5456b07..ca93349ad 100644
--- a/cw_core/lib/amount_converter.dart
+++ b/cw_core/lib/amount_converter.dart
@@ -6,6 +6,7 @@ class AmountConverter {
static const _moneroAmountDivider = 1000000000000;
static const _wowneroAmountLength = 11;
static const _wowneroAmountDivider = 100000000000;
+ static const _ethereumAmountDivider = 1000000000000000000;
static const _bitcoinAmountDivider = 100000000;
static const _bitcoinAmountLength = 8;
static final _bitcoinAmountFormat = NumberFormat()
@@ -18,6 +19,30 @@ class AmountConverter {
..maximumFractionDigits = _wowneroAmountLength
..minimumFractionDigits = 1;
+ static int amountStringToInt(CryptoCurrency cryptoCurrency, String amount) {
+ switch (cryptoCurrency) {
+ case CryptoCurrency.xmr:
+ return _moneroParseAmount(amount);
+ case CryptoCurrency.xhv:
+ case CryptoCurrency.xag:
+ case CryptoCurrency.xau:
+ case CryptoCurrency.xaud:
+ case CryptoCurrency.xbtc:
+ case CryptoCurrency.xcad:
+ case CryptoCurrency.xchf:
+ case CryptoCurrency.xcny:
+ case CryptoCurrency.xeur:
+ case CryptoCurrency.xgbp:
+ case CryptoCurrency.xjpy:
+ case CryptoCurrency.xnok:
+ case CryptoCurrency.xnzd:
+ case CryptoCurrency.xusd:
+ return _moneroParseAmount(amount);
+ default:
+ return 0;
+ }
+ }
+
static String amountIntToString(CryptoCurrency cryptoCurrency, int amount) {
switch (cryptoCurrency) {
case CryptoCurrency.xmr:
@@ -28,6 +53,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:
@@ -57,6 +84,11 @@ class AmountConverter {
static String _bitcoinAmountToString(int amount) => _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 String _wowneroAmountToString(int amount) => _wowneroAmountFormat
.format(cryptoAmountToDouble(amount: amount, divider: _wowneroAmountDivider));
}
diff --git a/cw_core/lib/crypto_currency.dart b/cw_core/lib/crypto_currency.dart
index 6881393ed..a738175c2 100644
--- a/cw_core/lib/crypto_currency.dart
+++ b/cw_core/lib/crypto_currency.dart
@@ -103,6 +103,7 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen
CryptoCurrency.kaspa,
CryptoCurrency.digibyte,
CryptoCurrency.usdtSol,
+ CryptoCurrency.btcln,
CryptoCurrency.usdcTrc20,
CryptoCurrency.tbtc,
CryptoCurrency.wow,
@@ -190,7 +191,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: 'sats', 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);
@@ -224,7 +225,6 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen
static const tbtc = CryptoCurrency(title: 'tBTC', fullName: 'Testnet Bitcoin', raw: 93, name: 'tbtc', iconPath: 'assets/images/tbtc.png', decimals: 8);
static const wow = CryptoCurrency(title: 'WOW', fullName: 'Wownero', raw: 94, name: 'wow', iconPath: 'assets/images/wownero_icon.png', decimals: 11);
-
static final Map _rawCurrencyMap =
[...all, ...havenCurrencies].fold