Count pending send reservations when branch spend is present#347
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
bf58915
into
codex/update-sigil-glyph-balance-logic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72474cd494
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (branchSpentScaled > 0n) { | ||
| return getReservedScaledForKind(canonical, "note") + getPendingReservedScaledForKind(canonical, "send"); | ||
| } |
There was a problem hiding this comment.
Avoid double-counting pending sends with branchSpentPhi
When branchSpentScaled > 0n, this now adds pending send reservations from the ledger on top of branchSpentPhi. In this component, send() already increments branchSpentPhi immediately (before confirmation), and the same transfer is still pending in the ledger until it’s received. In that common case (after a send in the same tab, before receive), the amount is subtracted twice, understating remaining Φ and potentially blocking valid sends. Consider only adding pending sends that aren’t already reflected in branchSpentPhi, or switching to confirmed-only ledger amounts when branchSpentPhi is maintained in-memory.
Useful? React with 👍 / 👎.
Motivation
branchSpentPhiis non-zero but the local ledger contains newer pendingsendreservations (e.g., from another tab), which can allow accidental over-exhale.sendreservations are counted even whenbranchSpentPhicauses the ledger check to narrow tonotekind only.Description
getPendingReservedScaledForKindinsrc/utils/sendLedger.tsto sum pending (unconfirmed) reservations bykind.sendreservations whenbranchSpentScaled > 0nby combininggetReservedScaledForKind(..., "note")withgetPendingReservedScaledForKind(..., "send")insrc/pages/SigilPage/useSigilSend.ts.src/pages/SigilPage/SigilPage.tsxandsrc/components/VerifierStamper/VerifierStamper.tsx, and updated the corresponding imports to include the new helper.Testing
Codex Task