Skip to content

Commit

Permalink
Merge branch 'main' into support/salvium
Browse files Browse the repository at this point in the history
  • Loading branch information
0xskydb authored Dec 10, 2024
2 parents cf466f4 + 6744bb8 commit a46c7dc
Show file tree
Hide file tree
Showing 158 changed files with 665 additions and 358 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/cache_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,24 @@ jobs:
/opt/android/cake_wallet/cw_salvium/android/.cxx
/opt/android/cake_wallet/scripts/monero_c/release
key: ${{ hashFiles('**/prepare_moneroc.sh' ,'**/build_monero_all.sh' ,'**/cache_dependencies.yml') }}

- if: ${{ steps.cache-externals.outputs.cache-hit != 'true' }}
name: Generate Externals
run: |
cd /opt/android/cake_wallet/scripts/android/
source ./app_env.sh cakewallet
./build_monero_all.sh
- name: Set up cache path
id: cache-path
run: echo "cache-file-path=/opt/android/cake_wallet/android/app/key.jks" >> $GITHUB_ENV

- name: Cache Keystore
id: cache-keystore
uses: actions/cache@v3
with:
path: /opt/android/cake_wallet/android/app/key.jks
key: $STORE_PASS
path: ${{ env.cache-file-path }}
key: keystore

- if: ${{ steps.cache-keystore.outputs.cache-hit != 'true' }}
name: Generate KeyStore
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/no_print_in_dart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: No print statements in dart files

on:
pull_request:
branches: [main]

jobs:
PR_test_build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: Check for print() statements in dart code (use printV() instead)
if: github.event_name == 'pull_request'
run: |
GIT_GREP_OUT="$(git grep ' print(' | (grep .dart: || test $? = 1) | (grep -v print_verbose.dart || test $? = 1) || true)"
[[ "x$GIT_GREP_OUT" == "x" ]] && exit 0
echo "$GIT_GREP_OUT"
echo "There are .dart files which use print() statements"
echo "Please use printV from package: cw_core/utils/print_verbose.dart"
exit 1
22 changes: 13 additions & 9 deletions .github/workflows/pr_test_build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,19 @@ jobs:
cd /opt/android/cake_wallet/scripts/android/
./build_mwebd.sh --dont-install
# - name: Cache Keystore
# id: cache-keystore
# uses: actions/cache@v3
# with:
# path: /opt/android/cake_wallet/android/app/key.jks
# key: $STORE_PASS
#
# - if: ${{ steps.cache-keystore.outputs.cache-hit != 'true' }}
- name: Generate KeyStore
- name: Set up cache path
id: cache-path
run: echo "cache-file-path=/opt/android/cake_wallet/android/app/key.jks" >> $GITHUB_ENV

- name: Cache Keystore
id: cache-keystore
uses: actions/cache@v3
with:
path: ${{ env.cache-file-path }}
key: keystore

- if: ${{ steps.cache-keystore.outputs.cache-hit != 'true' }}
name: Generate KeyStore
run: |
cd /opt/android/cake_wallet/android/app
keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias testKey -noprompt -dname "CN=CakeWallet, OU=CakeWallet, O=CakeWallet, L=Florida, S=America, C=USA" -storepass $STORE_PASS -keypass $KEY_PASS
Expand Down
1 change: 1 addition & 0 deletions cw_bitcoin/lib/bitcoin_hardware_wallet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:cw_bitcoin/utils.dart';
import 'package:cw_core/hardware/hardware_account_data.dart';
import 'package:ledger_bitcoin/ledger_bitcoin.dart';
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart';
import 'package:cw_core/utils/print_verbose.dart';

class BitcoinHardwareWalletService {
BitcoinHardwareWalletService(this.ledgerConnection);
Expand Down
17 changes: 9 additions & 8 deletions cw_bitcoin/lib/electrum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';
import 'dart:typed_data';
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:cw_bitcoin/bitcoin_amount_format.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:flutter/foundation.dart';
import 'package:rxdart/rxdart.dart';

Expand Down Expand Up @@ -117,17 +118,17 @@ class ElectrumClient {
_parseResponse(message);
}
} catch (e) {
print("socket.listen: $e");
printV("socket.listen: $e");
}
},
onError: (Object error) {
final errorMsg = error.toString();
print(errorMsg);
printV(errorMsg);
unterminatedString = '';
socket = null;
},
onDone: () {
print("SOCKET CLOSED!!!!!");
printV("SOCKET CLOSED!!!!!");
unterminatedString = '';
try {
if (host == socket?.address.host || socket == null) {
Expand All @@ -136,7 +137,7 @@ class ElectrumClient {
socket = null;
}
} catch (e) {
print("onDone: $e");
printV("onDone: $e");
}
},
cancelOnError: true,
Expand Down Expand Up @@ -181,7 +182,7 @@ class ElectrumClient {
unterminatedString = '';
}
} catch (e) {
print("parse $e");
printV("parse $e");
}
}

Expand Down Expand Up @@ -403,7 +404,7 @@ class ElectrumClient {
} on RequestFailedTimeoutException catch (_) {
return null;
} catch (e) {
print("getCurrentBlockChainTip: ${e.toString()}");
printV("getCurrentBlockChainTip: ${e.toString()}");
return null;
}
}
Expand Down Expand Up @@ -434,7 +435,7 @@ class ElectrumClient {

return subscription;
} catch (e) {
print("subscribe $e");
printV("subscribe $e");
return null;
}
}
Expand Down Expand Up @@ -473,7 +474,7 @@ class ElectrumClient {

return completer.future;
} catch (e) {
print("callWithTimeout $e");
printV("callWithTimeout $e");
rethrow;
}
}
Expand Down
5 changes: 3 additions & 2 deletions cw_bitcoin/lib/electrum_transaction_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:cw_bitcoin/electrum_transaction_info.dart';
import 'package:cw_core/pathForWallet.dart';
import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/utils/file.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/transaction_history.dart';
Expand Down Expand Up @@ -51,7 +52,7 @@ abstract class ElectrumTransactionHistoryBase
final data = json.encode({'height': _height, 'transactions': txjson});
await encryptionFileUtils.write(path: path, password: _password, data: data);
} catch (e) {
print('Error while save bitcoin transaction history: ${e.toString()}');
printV('Error while save bitcoin transaction history: ${e.toString()}');
}
}

Expand Down Expand Up @@ -88,7 +89,7 @@ abstract class ElectrumTransactionHistoryBase

_height = content['height'] as int;
} catch (e) {
print(e);
printV(e);
}
}

Expand Down
36 changes: 19 additions & 17 deletions cw_bitcoin/lib/electrum_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'dart:io';
import 'dart:isolate';

import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:cw_bitcoin/litecoin_wallet_addresses.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_bitcoin/bitcoin_wallet.dart';
import 'package:cw_bitcoin/litecoin_wallet.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down Expand Up @@ -479,8 +481,8 @@ abstract class ElectrumWalletBase
syncStatus = SyncedSyncStatus();
}
} catch (e, stacktrace) {
print(stacktrace);
print("startSync $e");
printV(stacktrace);
printV("startSync $e");
syncStatus = FailedSyncStatus();
}
}
Expand All @@ -506,7 +508,7 @@ abstract class ElectrumWalletBase
_feeRates = [slowFee, mediumFee, fastFee];
return;
} catch (e) {
print(e);
printV(e);
}
}

Expand Down Expand Up @@ -588,8 +590,8 @@ abstract class ElectrumWalletBase

await electrumClient.connectToUri(node.uri, useSSL: node.useSSL);
} catch (e, stacktrace) {
print(stacktrace);
print("connectToNode $e");
printV(stacktrace);
printV("connectToNode $e");
syncStatus = FailedSyncStatus();
}
}
Expand Down Expand Up @@ -1492,7 +1494,7 @@ abstract class ElectrumWalletBase
await unspentCoinsInfo.deleteAll(keys);
}
} catch (e) {
print("refreshUnspentCoinsInfo $e");
printV("refreshUnspentCoinsInfo $e");
}
}

Expand Down Expand Up @@ -1935,7 +1937,7 @@ abstract class ElectrumWalletBase

return historiesWithDetails;
} catch (e) {
print("fetchTransactions $e");
printV("fetchTransactions $e");
return {};
}
}
Expand Down Expand Up @@ -2059,7 +2061,7 @@ abstract class ElectrumWalletBase
}

Future<void> updateTransactions() async {
print("updateTransactions() called!");
printV("updateTransactions() called!");
try {
if (_isTransactionUpdating) {
return;
Expand Down Expand Up @@ -2091,8 +2093,8 @@ abstract class ElectrumWalletBase
walletAddresses.updateReceiveAddresses();
_isTransactionUpdating = false;
} catch (e, stacktrace) {
print(stacktrace);
print(e);
printV(stacktrace);
printV(e);
_isTransactionUpdating = false;
}
}
Expand All @@ -2110,13 +2112,13 @@ abstract class ElectrumWalletBase
try {
await _scripthashesUpdateSubject[sh]?.close();
} catch (e) {
print("failed to close: $e");
printV("failed to close: $e");
}
}
try {
_scripthashesUpdateSubject[sh] = await electrumClient.scripthashUpdate(sh);
} catch (e) {
print("failed scripthashUpdate: $e");
printV("failed scripthashUpdate: $e");
}
_scripthashesUpdateSubject[sh]?.listen((event) async {
try {
Expand All @@ -2126,15 +2128,15 @@ abstract class ElectrumWalletBase

await _fetchAddressHistory(address, await getCurrentChainTip());
} catch (e, s) {
print("sub error: $e");
printV("sub error: $e");
_onError?.call(FlutterErrorDetails(
exception: e,
stack: s,
library: this.runtimeType.toString(),
));
}
}, onError: (e, s) {
print("sub_listen error: $e $s");
printV("sub_listen error: $e $s");
});
}));
}
Expand Down Expand Up @@ -2186,7 +2188,7 @@ abstract class ElectrumWalletBase

if (balances.isNotEmpty && balances.first['confirmed'] == null) {
// if we got null balance responses from the server, set our connection status to lost and return our last known balance:
print("got null balance responses from the server, setting connection status to lost");
printV("got null balance responses from the server, setting connection status to lost");
syncStatus = LostConnectionSyncStatus();
return balance[currency] ?? ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0);
}
Expand All @@ -2213,7 +2215,7 @@ abstract class ElectrumWalletBase
}

Future<void> updateBalance() async {
print("updateBalance() called!");
printV("updateBalance() called!");
balance[currency] = await fetchBalances();
await save();
}
Expand Down Expand Up @@ -2353,7 +2355,7 @@ abstract class ElectrumWalletBase
}

void _syncStatusReaction(SyncStatus syncStatus) async {
print("SYNC_STATUS_CHANGE: ${syncStatus}");
printV("SYNC_STATUS_CHANGE: ${syncStatus}");
if (syncStatus is SyncingSyncStatus) {
return;
}
Expand Down
6 changes: 4 additions & 2 deletions cw_bitcoin/lib/electrum_wallet_addresses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'dart:io' show Platform;
import 'package:bitcoin_base/bitcoin_base.dart';
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:cw_bitcoin/bitcoin_address_record.dart';
import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_bitcoin/bitcoin_unspent.dart';
import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_info.dart';
Expand Down Expand Up @@ -193,7 +195,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
receiveAddresses.remove(addressRecord);
receiveAddresses.insert(0, addressRecord);
} catch (e) {
print("ElectrumWalletAddressBase: set address ($addr): $e");
printV("ElectrumWalletAddressBase: set address ($addr): $e");
}
}

Expand Down Expand Up @@ -483,7 +485,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {

await saveAddressesInBox();
} catch (e) {
print("updateAddresses $e");
printV("updateAddresses $e");
}
}

Expand Down
Loading

0 comments on commit a46c7dc

Please sign in to comment.