@@ -7,6 +7,7 @@ import com.synonym.bitkitcore.ActivityTags
77import com.synonym.bitkitcore.ClosedChannelDetails
88import com.synonym.bitkitcore.IcJitEntry
99import com.synonym.bitkitcore.LightningActivity
10+ import com.synonym.bitkitcore.OnchainActivity
1011import com.synonym.bitkitcore.PaymentState
1112import com.synonym.bitkitcore.PaymentType
1213import com.synonym.bitkitcore.SortDirection
@@ -191,6 +192,42 @@ class ActivityRepo @Inject constructor(
191192 }
192193 }
193194
195+ private suspend fun getOnchainActivityByTxId (txid : String ): OnchainActivity ? {
196+ return coreService.activity.getOnchainActivityByTxId(txid)
197+ }
198+
199+ /* *
200+ * Determines whether to show the payment received sheet for an onchain transaction.
201+ * Returns false for:
202+ * - Zero value transactions
203+ * - Channel closure transactions (transfers to savings)
204+ * - RBF replacement transactions with the same value as the original
205+ */
206+ suspend fun shouldShowReceivedSheet (txid : String , value : ULong ): Boolean = withContext(bgDispatcher) {
207+ if (value == 0uL ) return @withContext false
208+
209+ if (findClosedChannelForTransaction(txid) != null ) {
210+ Logger .debug(" Skipping received sheet for channel closure tx: $txid " , context = TAG )
211+ return @withContext false
212+ }
213+
214+ val onchainActivity = getOnchainActivityByTxId(txid)
215+ if (onchainActivity != null && onchainActivity.boostTxIds.isNotEmpty()) {
216+ for (replacedTxid in onchainActivity.boostTxIds) {
217+ val replacedActivity = getOnchainActivityByTxId(replacedTxid)
218+ if (replacedActivity != null && replacedActivity.value == value) {
219+ Logger .info(
220+ " Skipping received sheet for RBF replacement $txid with same value as $replacedTxid " ,
221+ context = TAG
222+ )
223+ return @withContext false
224+ }
225+ }
226+ }
227+
228+ return @withContext true
229+ }
230+
194231 /* *
195232 * Gets a specific activity by payment hash or txID with retry logic
196233 */
0 commit comments