Fix electrum unspent coins error (#1912)

* Refresh unspent coins before creating a transaction

* disable seed verification in debug mode [skip ci]
This commit is contained in:
Omar Hatem 2024-12-29 23:48:53 +02:00 committed by GitHub
parent 4cdee649d1
commit 214fc7113c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 5 deletions

View file

@ -4,7 +4,6 @@ import 'dart:io';
import 'dart:isolate'; import 'dart:isolate';
import 'package:bitcoin_base/bitcoin_base.dart'; 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_core/utils/print_verbose.dart';
import 'package:cw_bitcoin/bitcoin_wallet.dart'; import 'package:cw_bitcoin/bitcoin_wallet.dart';
import 'package:cw_bitcoin/litecoin_wallet.dart'; import 'package:cw_bitcoin/litecoin_wallet.dart';
@ -991,6 +990,9 @@ abstract class ElectrumWalletBase
@override @override
Future<PendingTransaction> createTransaction(Object credentials) async { Future<PendingTransaction> createTransaction(Object credentials) async {
try { try {
// start by updating unspent coins
await updateAllUnspents();
final outputs = <BitcoinOutput>[]; final outputs = <BitcoinOutput>[];
final transactionCredentials = credentials as BitcoinTransactionCredentials; final transactionCredentials = credentials as BitcoinTransactionCredentials;
final hasMultiDestination = transactionCredentials.outputs.length > 1; final hasMultiDestination = transactionCredentials.outputs.length > 1;

View file

@ -20,7 +20,8 @@ class SeedVerificationPage extends BasePage {
builder: (context) { builder: (context) {
return Padding( return Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: walletSeedViewModel.isVerificationComplete child: walletSeedViewModel.isVerificationComplete ||
walletSeedViewModel.verificationIndices.isEmpty
? SeedVerificationSuccessView( ? SeedVerificationSuccessView(
imageColor: titleColor(context), imageColor: titleColor(context),
) )

View file

@ -1,7 +1,9 @@
import 'package:flutter/foundation.dart';
class FeatureFlag { class FeatureFlag {
static const bool isCakePayEnabled = false; static const bool isCakePayEnabled = false;
static const bool isExolixEnabled = true; static const bool isExolixEnabled = true;
static const bool isInAppTorEnabled = false; static const bool isInAppTorEnabled = false;
static const bool isBackgroundSyncEnabled = false; static const bool isBackgroundSyncEnabled = false;
static const int verificationWordsCount = 2; static const int verificationWordsCount = kDebugMode ? 0 : 2;
} }

View file

@ -29,6 +29,7 @@ abstract class WalletSeedViewModelBase with Store {
List<String> get seedSplit => seed.split(RegExp(r'\s+')); List<String> get seedSplit => seed.split(RegExp(r'\s+'));
int get columnCount => seedSplit.length <= 16 ? 2 : 3; int get columnCount => seedSplit.length <= 16 ? 2 : 3;
double get columnAspectRatio => seedSplit.length <= 16 ? 1.8 : 2.8; double get columnAspectRatio => seedSplit.length <= 16 ? 1.8 : 2.8;
/// The indices of the seed to be verified. /// The indices of the seed to be verified.
@ -60,8 +61,10 @@ abstract class WalletSeedViewModelBase with Store {
bool isVerificationComplete = false; bool isVerificationComplete = false;
void setupSeedVerification() { void setupSeedVerification() {
generateRandomIndices(); if (verificationWordCount != 0) {
generateOptions(); generateRandomIndices();
generateOptions();
}
} }
/// Generate the indices of the seeds to be verified. /// Generate the indices of the seeds to be verified.