* fix(sp): proper address on details screen

* fix(sp): fields to update on incoming msg

* Update lib/bitcoin/cw_bitcoin.dart

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
rafael_xmr
2025-08-21 05:06:35 +03:00
committed by GitHub
co-authored by Omar Hatem
parent e15f130535
commit 16f058e9e2
4 changed files with 48 additions and 40 deletions
+24 -24
View File
@@ -403,6 +403,9 @@ abstract class ElectrumWalletBase
existingTxInfo.confirmations = tx.confirmations;
existingTxInfo.height = tx.height;
existingTxInfo.date = tx.date;
existingTxInfo.isReceivedSilentPayment = tx.isReceivedSilentPayment;
existingTxInfo.direction = tx.direction;
existingTxInfo.isPending = tx.isPending;
final newUnspents = tx.unspents!
.where((unspent) => !(existingTxInfo.unspents?.any((element) =>
@@ -2057,8 +2060,8 @@ abstract class ElectrumWalletBase
.where((type) => type != SegwitAddresType.mweb)
.map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
} else if (type == WalletType.dogecoin) {
await Future.wait(DOGECOIN_ADDRESS_TYPES.map(
(type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
await Future.wait(DOGECOIN_ADDRESS_TYPES
.map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
}
transactionHistory.transactions.values.forEach((tx) async {
@@ -2875,6 +2878,23 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
LogLevel.info,
);
void endScanningSuccesfully() {
if (scanData.isSingleScan)
scanData.sendPort.send(SyncResponse(syncHeight, SyncedSyncStatus()));
else
scanData.sendPort.send(
SyncResponse(syncHeight, SyncedTipSyncStatus(scanData.chainTip)),
);
_scanningStream?.close();
_scanningStream = null;
log(
"ended: syncHeight: $syncHeight, chainTip: ${scanData.chainTip}, isSingleScan: ${scanData.isSingleScan}",
LogLevel.info,
);
}
void listenFn(Map<String, dynamic> event, ElectrumTweaksSubscribe req) async {
final response = req.onResponse(event);
@@ -2883,9 +2903,6 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
"ending: response = $response, stream = $_scanningStream",
LogLevel.error,
);
scanData.sendPort.send(
SyncResponse(scanData.height, LostConnectionSyncStatus()),
);
return;
}
@@ -2896,9 +2913,7 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
if (scanData.isSingleScan) {
log("ending: noData and isSingleScan", LogLevel.info);
scanData.sendPort.send(
SyncResponse(scanData.height, LostConnectionSyncStatus()),
);
endScanningSuccesfully();
return;
}
@@ -3114,22 +3129,7 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
syncHeight = tweakHeight;
if ((tweakHeight >= scanData.chainTip) || scanData.isSingleScan) {
if (tweakHeight >= scanData.chainTip)
scanData.sendPort.send(
SyncResponse(syncHeight, SyncedTipSyncStatus(scanData.chainTip)),
);
if (scanData.isSingleScan) {
scanData.sendPort.send(SyncResponse(syncHeight, SyncedSyncStatus()));
}
_scanningStream?.close();
_scanningStream = null;
log(
"ending: syncHeight: $syncHeight, chainTip: ${scanData.chainTip}, isSingleScan: ${scanData.isSingleScan}",
LogLevel.info,
);
return;
endScanningSuccesfully();
}
}
+12 -6
View File
@@ -802,7 +802,7 @@ class CWBitcoin extends Bitcoin {
}
@override
String? getTransactionAddress(Object wallet, TransactionInfo tx) {
List<String>? getTransactionAddresses(Object wallet, TransactionInfo tx) {
final bitcoinWallet = wallet as BitcoinWallet;
final bitcoinTx = tx as ElectrumTransactionInfo;
@@ -810,10 +810,16 @@ class CWBitcoin extends Bitcoin {
return null;
}
// final bitcoinSPAddrs =
// bitcoinTx.unspents!.first.bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord;
final bitcoinSPAddrs = wallet.walletAddresses as BitcoinWalletAddresses;
final bitcoinSPAddr = bitcoinSPAddrs.silentAddresses.first;
return bitcoinSPAddr.address;
final addresses = <String>[];
final labels = <String>[];
try {
bitcoinTx.unspents!.forEach((unspent) {
addresses.add(bitcoinWallet.walletAddresses.silentAddresses
.firstWhere((address) => address.silentPaymentTweak == unspent.silentPaymentLabel)
.address);
});
} catch (e) {}
return addresses;
}
}
@@ -351,17 +351,19 @@ abstract class TransactionDetailsViewModelBase with Store {
if (wallet.type == WalletType.bitcoin && tx.direction == TransactionDirection.incoming) {
try {
final address = bitcoin!.getTransactionAddress(wallet, tx);
final addresses = bitcoin!.getTransactionAddresses(wallet, tx);
if (address != null) {
if (addresses != null) {
isRecipientAddressShown = true;
_items.add(
StandartListItem(
title: S.current.transaction_details_recipient_address,
value: address,
key: ValueKey('standard_list_item_transaction_details_recipient_address_key'),
),
);
for (final address in addresses) {
_items.add(
StandartListItem(
title: S.current.transaction_details_recipient_address,
value: address,
key: ValueKey('standard_list_item_transaction_details_recipient_address_key'),
),
);
}
}
} catch (e) {
printV(e.toString());
+1 -1
View File
@@ -259,7 +259,7 @@ abstract class Bitcoin {
void resumePayjoinSessions(Object wallet);
void stopPayjoinSessions(Object wallet);
Map<String, String> getSilentPaymentKeys(Object wallet);
String? getTransactionAddress(Object wallet, TransactionInfo tx);
List<String>? getTransactionAddresses(Object wallet, TransactionInfo tx);
}
""";