From 214fc7113c4a865029a38942cb0dadca9947dbe7 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Sun, 29 Dec 2024 23:48:53 +0200 Subject: [PATCH] Fix electrum unspent coins error (#1912) * Refresh unspent coins before creating a transaction * disable seed verification in debug mode [skip ci] --- cw_bitcoin/lib/electrum_wallet.dart | 4 +++- .../seed/seed_verification/seed_verification_page.dart | 3 ++- lib/utils/feature_flag.dart | 4 +++- lib/view_model/wallet_seed_view_model.dart | 7 +++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 3ab1505c9..9a7e45d05 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -4,7 +4,6 @@ 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'; @@ -991,6 +990,9 @@ abstract class ElectrumWalletBase @override Future createTransaction(Object credentials) async { try { + // start by updating unspent coins + await updateAllUnspents(); + final outputs = []; final transactionCredentials = credentials as BitcoinTransactionCredentials; final hasMultiDestination = transactionCredentials.outputs.length > 1; diff --git a/lib/src/screens/seed/seed_verification/seed_verification_page.dart b/lib/src/screens/seed/seed_verification/seed_verification_page.dart index 755cb2aae..ac03768ca 100644 --- a/lib/src/screens/seed/seed_verification/seed_verification_page.dart +++ b/lib/src/screens/seed/seed_verification/seed_verification_page.dart @@ -20,7 +20,8 @@ class SeedVerificationPage extends BasePage { builder: (context) { return Padding( padding: const EdgeInsets.all(16.0), - child: walletSeedViewModel.isVerificationComplete + child: walletSeedViewModel.isVerificationComplete || + walletSeedViewModel.verificationIndices.isEmpty ? SeedVerificationSuccessView( imageColor: titleColor(context), ) diff --git a/lib/utils/feature_flag.dart b/lib/utils/feature_flag.dart index efde5208d..593e0f216 100644 --- a/lib/utils/feature_flag.dart +++ b/lib/utils/feature_flag.dart @@ -1,7 +1,9 @@ +import 'package:flutter/foundation.dart'; + class FeatureFlag { static const bool isCakePayEnabled = false; static const bool isExolixEnabled = true; static const bool isInAppTorEnabled = false; static const bool isBackgroundSyncEnabled = false; - static const int verificationWordsCount = 2; + static const int verificationWordsCount = kDebugMode ? 0 : 2; } \ No newline at end of file diff --git a/lib/view_model/wallet_seed_view_model.dart b/lib/view_model/wallet_seed_view_model.dart index 5355c856d..53c76ed10 100644 --- a/lib/view_model/wallet_seed_view_model.dart +++ b/lib/view_model/wallet_seed_view_model.dart @@ -29,6 +29,7 @@ abstract class WalletSeedViewModelBase with Store { List get seedSplit => seed.split(RegExp(r'\s+')); int get columnCount => seedSplit.length <= 16 ? 2 : 3; + double get columnAspectRatio => seedSplit.length <= 16 ? 1.8 : 2.8; /// The indices of the seed to be verified. @@ -60,8 +61,10 @@ abstract class WalletSeedViewModelBase with Store { bool isVerificationComplete = false; void setupSeedVerification() { - generateRandomIndices(); - generateOptions(); + if (verificationWordCount != 0) { + generateRandomIndices(); + generateOptions(); + } } /// Generate the indices of the seeds to be verified.