Repository navigation
Conversation
…ot be funded A permission token costs a little to mint. In a wallet with no spendable coins the mint fails with WERR_INSUFFICIENT_FUNDS and the user's decision was dropped with it: grantPersistentPermission skipped cachePermission and markRecentGrant, so the next identical call prompted again, and a grouped or counterparty grant rejected the call that was waiting on it. - On WERR_INSUFFICIENT_FUNDS only, the grant is kept in memory for the life of the manager (until its expiry) and checked with the other grant caches. - Grouped and counterparty grants resume their waiting call in that case. - The grant call still throws the funding error; nothing is persisted, so the next session asks again and a funded wallet mints as before. - Spending authorizations are never kept without a token, and every other mint failure still re-opens the prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 16, 2026
Draft
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Program and scope
WERR_INSUFFICIENT_FUNDSand the user's decision is dropped with it. IngrantPersistentPermission(src/WalletPermissionsManager.ts1103 to 1148 at 2.14.5,2fd579cb), the throw fromawait mint(1140) skipscachePermissionandmarkRecentGrant(1146 to 1147), so the next identical call prompts again. A grouped or counterparty grant goes further and rejects the call waiting on it (1314, 1463), becausepersistPermissionGrant(1369) throws. The error itself is raised promptly (storage/methods/generateChange.ts199); the cost is the repeated prompt.What was seen
BSV Desktop 3.1.1 (bundling wallet-toolbox 2.14.5) on a fresh wallet, connecting to a BRC-100 web app that signs in with BRC-103:
auth message signature, this app and counterparty); each was granted, and on the next attempt the wallet asked for the same permissions again. The app never connected.The change
WERR_INSUFFICIENT_FUNDSonly, the grant is kept in memory (sessionGrants) for the life of the manager, until its own expiry, and is checked alongside the existing grant caches inhasRecentOrPendingGrantCore.settleFailedGrant).The principle behind it: a grant is the user's decision, and the token is the wallet's record of it. A wallet that cannot afford the record should still honor the decision for as long as it is running, rather than ask again.
Impact
No exports or types change. Behavior changes only after a mint fails for lack of funds: the waiting grouped or counterparty call resolves instead of rejecting, and the same permission is not asked for again in this session. The boundary is the permission check itself. A kept grant is the one the user approved, keyed exactly as the token would be and limited by its expiry.
Affected packages/services and intended patch versions:
@bsv/wallet-toolbox,-clientand-mobile, joining the pending 2.15.0 notes (CHANGELOG andgovernance/package-release-notes.jsonupdated;docs/reference/package-api-migrations.mdregenerated).Verification
pnpm install --frozen-lockfile --ignore-scripts):src/__tests/WalletPermissionsManager.unfundedGrant.test.ts, RED onmain(cf6f1c08): 3 of 4 fail (a second prompt,Expected: 1 Received: 2; the grouped waiterrejected instead of resolvedwithWERR_INSUFFICIENT_FUNDS; no session store). The expiry case is a boundary check and passes before and after. GREEN: 4 of 4.jest WalletPermissionsManager: 22 suites, 289 tests passed.testpatterns) before building: 296 suites passed, 2 skipped; 6 suites failed only because they load the builtout/. Afterpnpm buildthose 6 suites pass (74 tests).pnpm typecheck(wallet-toolbox),pnpm lint,pnpm format:check,pnpm health:check: pass.compatibility, public API, artifacts, dependencies, docs, and operations
scope-based skip is expected and validated by the merge gate
Security and dependencies
audit results were reviewed
(including accepted or false-positive issue states) and zero unreviewed hotspots;
Sonar's aggregate
Quality Gate passedverdict alone is not merge evidenceand removal condition
Notes for review
🤖 Generated with Claude Code