Repository navigation
Settles amount automatically if min and max are equal in lnurl condit… - #330
Conversation
Deploying wallet-bitcoin with
|
| Latest commit: |
77573bb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://da699a5c.wallet-bitcoin.pages.dev |
| Branch Preview URL: | https://hotfix-lnurl.wallet-bitcoin.pages.dev |
Deploying wallet-mutinynet with
|
| Latest commit: |
77573bb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://54fbbe28.arkade-wallet.pages.dev |
| Branch Preview URL: | https://hotfix-lnurl.arkade-wallet.pages.dev |
WalkthroughThe change adds automatic satoshi amount assignment when LNURL returns identical minimum and maximum limits. When these bounds collapse to a single value, the code auto-sets satoshis to the minimum limit (converted from millisatoshis) before updating the LNURL limits. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/screens/Wallet/Send/Form.tsx (1)
185-191:⚠️ Potential issue | 🟠 MajorUse a functional updater to prevent stale
sendInfooverwrites in async LNURL callback.At line 190,
setSendInfo({ ...sendInfo, satoshis: min })capturessendInfoinside an async callback. SincecheckLnUrlConditionsperforms a network fetch with variable latency, other state updates can occur while waiting. When the promise resolves, this captured state snapshot overwrites newer fields that were set concurrently, such asarkAddress.Replace with a functional updater to apply the change against the latest state:
Suggested patch
- if (min === max) setSendInfo({ ...sendInfo, satoshis: min }) // set amount automatically + if (min === max) { + setSendInfo((prev) => ({ ...prev, satoshis: min })) // set amount automatically + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/screens/Wallet/Send/Form.tsx` around lines 185 - 191, The async LNURL callback in checkLnUrlConditions currently uses the captured sendInfo when calling setSendInfo, which can overwrite newer state; change setSendInfo to use the functional updater form so the update merges satoshis into the latest state (pass a function that receives the previous state and returns a new object spreading previous and setting satoshis to min), and keep the rest of the callback behavior (still call setLnUrlLimits and setError as appropriate) to avoid stale overwrites of fields like arkAddress.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/screens/Wallet/Send/Form.tsx`:
- Around line 185-191: The async LNURL callback in checkLnUrlConditions
currently uses the captured sendInfo when calling setSendInfo, which can
overwrite newer state; change setSendInfo to use the functional updater form so
the update merges satoshis into the latest state (pass a function that receives
the previous state and returns a new object spreading previous and setting
satoshis to min), and keep the rest of the callback behavior (still call
setLnUrlLimits and setError as appropriate) to avoid stale overwrites of fields
like arkAddress.
…ions
Summary by CodeRabbit