fix: detect confirmed onchain deposits after tab switch#2092
fix: detect confirmed onchain deposits after tab switch#2092im-adithya wants to merge 2 commits intomasterfrom
Conversation
📝 WalkthroughWalkthroughAdded a startTimeRef used to delay processing until initialized, prioritized unconfirmed UTXOs with an early return, and if none found, select confirmed UTXOs whose block_time is >= startTimeRef, updating txId/confirmedAmount and clearing pendingAmount accordingly. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/screens/wallet/receive/ReceiveOnchain.tsx (1)
106-110: Reset the detection baseline when the receive address changes.
startTimeRefis initialized only once (Line 106), so ifonchainAddressrotates, the confirmed-UTXO filter keeps using an old timestamp window. Re-initialize per address to avoid stale matching behavior.Proposed adjustment
- useEffect(() => { - if (startTimeRef.current === 0) { - startTimeRef.current = Math.floor(Date.now() / 1000); - } - }, []); + useEffect(() => { + if (!onchainAddress) return; + startTimeRef.current = Math.floor(Date.now() / 1000); + setTxId(""); + setConfirmedAmount(null); + setPendingAmount(null); + }, [onchainAddress]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/screens/wallet/receive/ReceiveOnchain.tsx` around lines 106 - 110, The current useEffect only initializes startTimeRef once so when onchainAddress changes the confirmed-UTXO detection still uses the old timestamp; update the effect to depend on onchainAddress and reset startTimeRef.current to Math.floor(Date.now()/1000) whenever onchainAddress changes. Locate the useEffect that sets startTimeRef and change it to run on [onchainAddress] (or include onchainAddress in the dependency array) and set startTimeRef.current = 0 or the new timestamp inside the effect so the confirmed-UTXO filter uses a fresh baseline for each new onchainAddress.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/screens/wallet/receive/ReceiveOnchain.tsx`:
- Around line 106-110: The current useEffect only initializes startTimeRef once
so when onchainAddress changes the confirmed-UTXO detection still uses the old
timestamp; update the effect to depend on onchainAddress and reset
startTimeRef.current to Math.floor(Date.now()/1000) whenever onchainAddress
changes. Locate the useEffect that sets startTimeRef and change it to run on
[onchainAddress] (or include onchainAddress in the dependency array) and set
startTimeRef.current = 0 or the new timestamp inside the effect so the
confirmed-UTXO filter uses a fresh baseline for each new onchainAddress.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/src/screens/onchain/DepositBitcoin.tsxfrontend/src/screens/wallet/receive/ReceiveOnchain.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/screens/onchain/DepositBitcoin.tsx
|
|
||
| useEffect(() => { | ||
| if (!mempoolAddressUtxos || mempoolAddressUtxos.length === 0) { | ||
| if (startTimeRef.current === 0) { |
Fixes #2087
Adds logic to also check for
confirmedtransactions in case the user never goes to the page after copying addressSummary by CodeRabbit