sp improv (#2437)
* 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>
rafael_xmr committed
Aug 20, 2025 at 23:06 UTC
16f058e9e2336520db942be0b241582be32fbec4
4 files changed
+48
-40
cw_bitcoin/lib/electrum_wallet.dart
+24
-24
@@ -403,6 +403,9 @@ abstract class ElectrumWalletBase
403
existingTxInfo.confirmations = tx.confirmations;
404
existingTxInfo.height = tx.height;
405
existingTxInfo.date = tx.date;
406
+ existingTxInfo.isReceivedSilentPayment = tx.isReceivedSilentPayment;
407
+ existingTxInfo.direction = tx.direction;
408
+ existingTxInfo.isPending = tx.isPending;
409
410
final newUnspents = tx.unspents!
411
.where((unspent) => !(existingTxInfo.unspents?.any((element) =>
@@ -2057,8 +2060,8 @@ abstract class ElectrumWalletBase
2060
.where((type) => type != SegwitAddresType.mweb)
2061
.map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
2062
} else if (type == WalletType.dogecoin) {
2060
- await Future.wait(DOGECOIN_ADDRESS_TYPES.map(
2061
- (type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
2063
+ await Future.wait(DOGECOIN_ADDRESS_TYPES
2064
+ .map((type) => fetchTransactionsForAddressType(historiesWithDetails, type)));
2065
}
2066
2067
transactionHistory.transactions.values.forEach((tx) async {
@@ -2875,6 +2878,23 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
2878
LogLevel.info,
2879
);
2880
2881
+ void endScanningSuccesfully() {
2882
+ if (scanData.isSingleScan)
2883
+ scanData.sendPort.send(SyncResponse(syncHeight, SyncedSyncStatus()));
2884
+ else
2885
+ scanData.sendPort.send(
2886
+ SyncResponse(syncHeight, SyncedTipSyncStatus(scanData.chainTip)),
2887
+ );
2888
+
2889
+ _scanningStream?.close();
2890
+ _scanningStream = null;
2891
+
2892
+ log(
2893
+ "ended: syncHeight: $syncHeight, chainTip: ${scanData.chainTip}, isSingleScan: ${scanData.isSingleScan}",
2894
+ LogLevel.info,
2895
+ );
2896
+ }
2897
+
2898
void listenFn(Map<String, dynamic> event, ElectrumTweaksSubscribe req) async {
2899
final response = req.onResponse(event);
2900
@@ -2883,9 +2903,6 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
2903
"ending: response = $response, stream = $_scanningStream",
2904
LogLevel.error,
2905
);
2886
- scanData.sendPort.send(
2887
- SyncResponse(scanData.height, LostConnectionSyncStatus()),
2888
- );
2906
return;
2907
}
2908
@@ -2896,9 +2913,7 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
2913
if (scanData.isSingleScan) {
2914
log("ending: noData and isSingleScan", LogLevel.info);
2915
2899
- scanData.sendPort.send(
2900
- SyncResponse(scanData.height, LostConnectionSyncStatus()),
2901
- );
2916
+ endScanningSuccesfully();
2917
return;
2918
}
2919
@@ -3114,22 +3129,7 @@ Future<void> _handleScanSilentPayments(ScanData scanData) async {
3129
syncHeight = tweakHeight;
3130
3131
if ((tweakHeight >= scanData.chainTip) || scanData.isSingleScan) {
3117
- if (tweakHeight >= scanData.chainTip)
3118
- scanData.sendPort.send(
3119
- SyncResponse(syncHeight, SyncedTipSyncStatus(scanData.chainTip)),
3120
- );
3121
-
3122
- if (scanData.isSingleScan) {
3123
- scanData.sendPort.send(SyncResponse(syncHeight, SyncedSyncStatus()));
3124
- }
3125
-
3126
- _scanningStream?.close();
3127
- _scanningStream = null;
3128
- log(
3129
- "ending: syncHeight: $syncHeight, chainTip: ${scanData.chainTip}, isSingleScan: ${scanData.isSingleScan}",
3130
- LogLevel.info,
3131
- );
3132
- return;
3132
+ endScanningSuccesfully();
3133
}
3134
}
3135
lib/bitcoin/cw_bitcoin.dart
+12
-6
@@ -802,7 +802,7 @@ class CWBitcoin extends Bitcoin {
802
}
803
804
@override
805
- String? getTransactionAddress(Object wallet, TransactionInfo tx) {
805
+ List<String>? getTransactionAddresses(Object wallet, TransactionInfo tx) {
806
final bitcoinWallet = wallet as BitcoinWallet;
807
final bitcoinTx = tx as ElectrumTransactionInfo;
808
@@ -810,10 +810,16 @@ class CWBitcoin extends Bitcoin {
810
return null;
811
}
812
813
- // final bitcoinSPAddrs =
814
- // bitcoinTx.unspents!.first.bitcoinAddressRecord as BitcoinSilentPaymentAddressRecord;
815
- final bitcoinSPAddrs = wallet.walletAddresses as BitcoinWalletAddresses;
816
- final bitcoinSPAddr = bitcoinSPAddrs.silentAddresses.first;
817
- return bitcoinSPAddr.address;
813
+ final addresses = <String>[];
814
+ final labels = <String>[];
815
+ try {
816
+ bitcoinTx.unspents!.forEach((unspent) {
817
+ addresses.add(bitcoinWallet.walletAddresses.silentAddresses
818
+ .firstWhere((address) => address.silentPaymentTweak == unspent.silentPaymentLabel)
819
+ .address);
820
+ });
821
+ } catch (e) {}
822
+
823
+ return addresses;
824
}
825
}
lib/view_model/transaction_details_view_model.dart
+11
-9
@@ -351,17 +351,19 @@ abstract class TransactionDetailsViewModelBase with Store {
351
352
if (wallet.type == WalletType.bitcoin && tx.direction == TransactionDirection.incoming) {
353
try {
354
- final address = bitcoin!.getTransactionAddress(wallet, tx);
354
+ final addresses = bitcoin!.getTransactionAddresses(wallet, tx);
355
356
- if (address != null) {
356
+ if (addresses != null) {
357
isRecipientAddressShown = true;
358
- _items.add(
359
- StandartListItem(
360
- title: S.current.transaction_details_recipient_address,
361
- value: address,
362
- key: ValueKey('standard_list_item_transaction_details_recipient_address_key'),
363
- ),
364
- );
358
+ for (final address in addresses) {
359
+ _items.add(
360
+ StandartListItem(
361
+ title: S.current.transaction_details_recipient_address,
362
+ value: address,
363
+ key: ValueKey('standard_list_item_transaction_details_recipient_address_key'),
364
+ ),
365
+ );
366
+ }
367
}
368
} catch (e) {
369
printV(e.toString());
tool/configure.dart
+1
-1
@@ -259,7 +259,7 @@ abstract class Bitcoin {
259
void resumePayjoinSessions(Object wallet);
260
void stopPayjoinSessions(Object wallet);
261
Map<String, String> getSilentPaymentKeys(Object wallet);
262
- String? getTransactionAddress(Object wallet, TransactionInfo tx);
262
+ List<String>? getTransactionAddresses(Object wallet, TransactionInfo tx);
263
}
264
""";
265