User accounts
Vaults, free funds, deposits, and withdrawals.
Provider wallet counters
initialize_provider_wallet creates the canonical owner/market ledger. The owner and payer sign. grow_provider_wallet adds storage without changing history. New reservations need room for a new provider row when that provider has no existing row.
prune_provider_wallet removes only rows with zero outstanding bookings whose rate windows have expired. close_provider_wallet requires every row to satisfy the same condition and returns storage funds to the recorded payer. Neither operation lets a wallet reset a live rate window or escape outstanding counts. Booking generations remain independent.
The ledger has a 112-byte header and 48-byte provider rows. A stored usage index is a hint; settlement checks the full provider identity. A wallet ledger is writable across its requests, so requests from one signing wallet still share that account lock.
Initialize and fund a user account
A User account records owner, market, free payment balance, vault, generation counter, and vault-authority bump. The owner signs initialize_user. Supply a fresh user-account signer; Anchor creates its storage.
Prepare the payment-token vault first. Its authority is the PDA derived from b"vault" and the user-account address. The vault must use the market mint and have no delegate, close authority, or native-SOL state. The account constraints bind this vault to the user.
deposit(amount) requires a positive amount in payment atoms. The owner signs a checked transfer from an owner-controlled token account into the vault. The program increases User.free by that amount. A direct token transfer into the vault does not update this accounting balance.
Withdraw free balance
withdraw(amount) requires the user owner’s signature, a positive amount, and enough free balance. The destination must use the market mint and belong to that owner. The program reduces User.free and transfers from its recorded vault.
A booking removes its full reservation from free balance. Tokens remain in the vault until settlement. Unused reserve becomes free after settlement, release, or executed expiry. The vault’s total token balance therefore does not show the immediately withdrawable amount.
The current program exposes no user-account closure instruction. Booking-account closure is separate.
Decode user state
This function receives raw account data and the expected identities. It checks ownership, the generated discriminator, and the decoded owner and market. Vault authority and token-account validation remain separate checks. The program’s state types define the layout.