From 5545137047f0d0a9cebdabec5c4d8e97a1baf568 Mon Sep 17 00:00:00 2001 From: Rafael Date: Fri, 31 May 2024 08:55:28 -0300 Subject: [PATCH] Sp fixes (#1471) * feat: missing desktop setting menu * fix: sp utxo pending --- cw_bitcoin/lib/electrum_wallet.dart | 19 ++++++++++++++++++- cw_bitcoin/pubspec.lock | 4 ++-- lib/src/widgets/setting_actions.dart | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 96f871a4b..43bae2e19 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -1465,7 +1465,7 @@ abstract class ElectrumWalletBase time = status["block_time"] as int?; final height = status["block_height"] as int? ?? 0; - final tip = await getCurrentChainTip(); + final tip = await getUpdatedChainTip(); if (tip > 0) confirmations = height > 0 ? tip - height + 1 : 0; } else { final verboseTransaction = await electrumClient.getTransactionRaw(hash: hash); @@ -1519,6 +1519,23 @@ abstract class ElectrumWalletBase await fetchTransactionsForAddressType(historiesWithDetails, SegwitAddresType.p2wpkh); } + transactionHistory.transactions.values.forEach((tx) async { + final isPendingSilentPaymentUtxo = + (tx.isPending || tx.confirmations == 0) && historiesWithDetails[tx.id] == null; + + if (isPendingSilentPaymentUtxo) { + final info = + await fetchTransactionInfo(hash: tx.id, height: tx.height, retryOnFailure: true); + + if (info != null) { + tx.confirmations = info.confirmations; + tx.isPending = tx.confirmations == 0; + transactionHistory.addOne(tx); + await transactionHistory.save(); + } + } + }); + return historiesWithDetails; } catch (e) { print(e.toString()); diff --git a/cw_bitcoin/pubspec.lock b/cw_bitcoin/pubspec.lock index 3eadcb112..997ed9452 100644 --- a/cw_bitcoin/pubspec.lock +++ b/cw_bitcoin/pubspec.lock @@ -793,8 +793,8 @@ packages: dependency: "direct main" description: path: "." - ref: "sp_v1.0.0" - resolved-ref: a9a4c6d051f37a15a3a52cc2a0094f24c68b62c5 + ref: "sp_v2.0.0" + resolved-ref: "62c152b9086cd968019128845371072f7e1168de" url: "https://github.com/cake-tech/sp_scanner" source: git version: "0.0.1" diff --git a/lib/src/widgets/setting_actions.dart b/lib/src/widgets/setting_actions.dart index 6fbdb6868..272ed57c2 100644 --- a/lib/src/widgets/setting_actions.dart +++ b/lib/src/widgets/setting_actions.dart @@ -29,6 +29,7 @@ class SettingActions { connectionSettingAction, walletSettingAction, addressBookSettingAction, + silentPaymentsSettingAction, securityBackupSettingAction, privacySettingAction, displaySettingAction,