Skip to content

Commit c87b13d

Browse files
committed
[trello.com/c/Aw0Vfnmd] Handle case when user sends money from regular account to a secret one.
1 parent 7b46536 commit c87b13d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

Adamant/Services/AdamantCoinStorageService.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class AdamantCoinStorageService: NSObject, CoinStorageService {
2323
private var subscriptions = Set<AnyCancellable>()
2424

2525
@ObservableValue private var transactions: [TransactionDetails] = []
26-
26+
2727
var transactionsPublisher: any Observable<[TransactionDetails]> {
2828
$transactions
2929
}
@@ -107,7 +107,7 @@ private extension AdamantCoinStorageService {
107107
)
108108
.sink { [weak self] notification in
109109
let changes = notification.managedObjectContextChanges(of: CoinTransaction.self)
110-
110+
111111
guard self != nil, self?.coinId != nil && self?.coinAddress != nil else {
112112
return
113113
}
@@ -130,7 +130,26 @@ private extension AdamantCoinStorageService {
130130
})
131131
else { return }
132132

133-
self?.transactions[index] = coinTransaction
133+
/*
134+
Workaround to correctly set isOutgoing when multiple transactions share the same txId across different accounts.
135+
136+
This situation can happen when sending funds from a regular account to a secret one — technically two different transactions, but with the same txId.
137+
Currently, there's no reliable way to assign a truly unique ID to each TransactionDetails instance, so this workaround helps distinguish them for now.
138+
PR - https://github.com/Adamant-im/adamant-iOS/pull/741
139+
*/
140+
self?.transactions[index] = SimpleTransactionDetails(
141+
defaultCurrencySymbol: coinTransaction.defaultCurrencySymbol,
142+
txId: coinTransaction.txId,
143+
senderAddress: coinTransaction.senderAddress,
144+
recipientAddress: coinTransaction.recipientAddress,
145+
dateValue: coinTransaction.dateValue,
146+
amountValue: coinTransaction.amountValue,
147+
feeValue: coinTransaction.feeValue,
148+
confirmationsValue: coinTransaction.confirmationsValue,
149+
blockValue: coinTransaction.blockValue,
150+
isOutgoing: self?.coinAddress == coinTransaction.senderAddress ? true : false,
151+
transactionStatus: coinTransaction.transactionStatus,
152+
nonceRaw: coinTransaction.nonceRaw)
134153
}
135154
}
136155
}

0 commit comments

Comments
 (0)