Skip to content

Commit 2cdfea4

Browse files
committed
fix: wire up DashPay payment history to wallet transactions
The Payment History screen was always empty because it only read from the dashpay_payments database table, which was only populated when payments were sent through the app's DashPay UI. The process_incoming_payment() function existed but was never called. Changes: - Add scan_wallet_transactions_for_dashpay_payments() that cross- references SPV wallet transactions against DashPay address mappings and saves matches to the dashpay_payments table (idempotent) - Call it from LoadPaymentHistory backend task for immediate retroactive detection when the user opens the Payment History screen - Call it during SPV reconcile for ongoing automatic detection - Fix ContactDetailsScreen to load per-contact payment history from DB (was initialized empty and never populated) Closes #688
1 parent 594c556 commit 2cdfea4

8 files changed

Lines changed: 542 additions & 34 deletions

File tree

src/backend_task/dashpay.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,40 @@ impl AppContext {
171171
),
172172
DashPayTask::LoadPaymentHistory { identity } => {
173173
let identity_id = identity.identity.id();
174+
175+
// Retroactively scan wallet transactions for DashPay payments
176+
// that may not yet be in the dashpay_payments table.
177+
// Clone transactions and drop the read lock before scanning
178+
// to reduce lock contention.
179+
// Iterate all associated wallets — an identity can have multiple.
180+
for wallet_arc in identity.associated_wallets.values() {
181+
let wallet_txs = match wallet_arc.read() {
182+
Ok(guard) => guard.transactions.clone(),
183+
Err(_) => continue,
184+
};
185+
186+
if wallet_txs.is_empty() {
187+
continue;
188+
}
189+
190+
match incoming_payments::scan_wallet_transactions_for_dashpay_payments(
191+
self,
192+
&identity_id,
193+
&wallet_txs,
194+
) {
195+
Ok(n) if n > 0 => {
196+
tracing::info!(
197+
"Retroactively discovered {} DashPay payment(s) from wallet transactions",
198+
n
199+
);
200+
}
201+
Err(e) => {
202+
tracing::warn!("Wallet transaction scan failed: {}", e);
203+
}
204+
_ => {}
205+
}
206+
}
207+
174208
let records = payments::load_payment_history(self, &identity_id, None)
175209
.await
176210
.map_err(

0 commit comments

Comments
 (0)