Invisible wallets only apply when using PAYMENT_PROVIDER=crypto. AirTM mode uses traditional fiat accounts instead.
Wallets Guide
Understanding invisible wallets in OFFER-HUB — automatic Stellar wallet creation and management.
OFFER-HUB uses "invisible wallets" to give users blockchain capabilities without the complexity of managing private keys. Every user gets a Stellar wallet automatically, but they interact with it like a simple account balance.
What Are Invisible Wallets?
Traditional crypto requires users to:
- Install wallet software
- Secure a seed phrase
- Understand gas fees
- Sign transactions manually
OFFER-HUB eliminates all of this. Users see a simple USD balance while the system manages Stellar wallets behind the scenes.
How It Works
Benefits
| Benefit | Description |
|---|---|
| No wallet setup | Users register with email, wallet created automatically |
| No seed phrases | Private keys secured server-side |
| No gas management | Platform handles Stellar transaction fees |
| Familiar UX | Users see USD, not crypto amounts |
| Full custody | Users can still withdraw to external wallets |
Wallet Creation
When a user is created, a Stellar keypair is generated automatically:
Behind the scenes:
- Generate keypair — New Stellar Ed25519 keypair created
- Encrypt private key — AES-256-GCM with
WALLET_ENCRYPTION_KEY - Store in database — Encrypted key saved with user record
- Fund account — Platform funds the account with minimum XLM for trustlines
- Add USDC trustline — Account configured to hold USDC
Response
The Stellar address is not included in the user response. Retrieve it separately via the deposit endpoint.
Getting the Deposit Address
Retrieve the user's Stellar address for receiving USDC:
Response
Display to Users
Show users their deposit address with clear instructions:
Checking Balance
Get the user's current balance:
Response
Balance Types
| Field | Description |
|---|---|
available | Can be used for orders or withdrawn |
reserved | Locked for pending orders (before escrow funding) |
Balance States During Order
| Stage | Available | Reserved |
|---|---|---|
| Initial deposit | 100.00 | 0.00 |
| After order reserve | 50.00 | 50.00 |
| After escrow funding | 50.00 | 0.00 |
| After release (seller) | 50.00 + payment | 0.00 |
Wallet Security
Encryption
Private keys are encrypted using AES-256-GCM:
The encryption process:
- Generate random 12-byte IV
- Encrypt private key with AES-256-GCM
- Store:
IV || ciphertext || authTag - Decrypt only when signing transactions
Key Management
The WALLET_ENCRYPTION_KEY protects ALL user private keys. If lost, wallet access is permanently lost. Back up this key securely and never commit it to version control.
Best practices:
- Generate securely — Use cryptographically secure random bytes
- Store in vault — Use HashiCorp Vault, AWS KMS, or platform secrets
- Rotate periodically — Plan for key rotation (re-encrypt all wallets)
- Separate environments — Use different keys for dev/staging/production
- Backup offline — Store encrypted backup in secure physical location
Generating the Encryption Key
Transaction Signing
When the user performs an action that requires on-chain activity (funding escrow, withdrawing), the system:
- Load encrypted key — Retrieve from database
- Decrypt in memory — Use
WALLET_ENCRYPTION_KEY - Build transaction — Create Stellar transaction
- Sign transaction — Sign with decrypted private key
- Submit to network — Send to Stellar Horizon
- Clear memory — Wipe decrypted key from memory
Decrypted private keys exist only in memory during transaction signing and are immediately cleared. They are never logged or written to disk.
Using the SDK
Listening for Balance Changes
On-Chain vs Off-Chain
OFFER-HUB maintains both on-chain (Stellar) and off-chain (database) balances:
On-Chain (Stellar)
- Actual USDC in the Stellar wallet
- Updated when deposits received or withdrawals sent
- Source of truth for blockchain state
- Can be verified on any Stellar explorer
Off-Chain (Database)
- Fast read/write for operations
- Tracks
availablevsreservedsplit - Used for reservations and internal transfers
- Synced with on-chain balance
Reconciliation
The system automatically reconciles on-chain and off-chain balances:
If discrepancies are detected, the system:
- Logs the discrepancy
- Syncs off-chain to match on-chain
- Alerts operators for review
Testnet vs Mainnet
Testnet (Development)
- Use Stellar testnet friendbot for XLM
- Test USDC from Circle's testnet faucet
- No real value at stake
Mainnet (Production)
- Real USDC from Circle
- Real XLM for transaction fees
- Production security required
Always test thoroughly on testnet before deploying to mainnet. On-chain transactions are irreversible.
Platform Wallet
The platform also has a wallet used for:
- Funding new accounts — Provides minimum XLM for trustlines
- Collecting fees — Receives platform fees from orders
- Co-signing escrow — Signs release/refund transactions
Configure in environment:
Ensure the platform wallet is funded with sufficient XLM for operations.
Error Handling
| Error | Cause | Solution |
|---|---|---|
WALLET_NOT_FOUND | User doesn't have a wallet | Ensure user was created in crypto mode |
INSUFFICIENT_BALANCE | Not enough USDC | User needs to deposit more |
TRUSTLINE_MISSING | Account can't hold USDC | Platform needs to add trustline |
DECRYPTION_FAILED | Invalid encryption key | Check WALLET_ENCRYPTION_KEY |
Next Steps
- Deposits Guide — How deposits work
- Withdrawals Guide — Moving funds off-platform
- Escrow Guide — Smart contract escrow flow