feat: add wallet generation script and wallet API endpoints#577
Merged
cardosofede merged 10 commits intodevelopmentfrom Dec 31, 2025
Merged
feat: add wallet generation script and wallet API endpoints#577cardosofede merged 10 commits intodevelopmentfrom
cardosofede merged 10 commits intodevelopmentfrom
Conversation
Add scripts/create-wallet.ts for secure client-side wallet generation: - Generates Solana keypair locally using @solana/web3.js - Displays address and private key with backup warnings - Requires user confirmation before adding to Gateway - Supports --no-add flag for generate-only mode - Supports --gateway flag for custom Gateway URL Usage: pnpm wallet:create Security: Private key is generated locally and only sent to Gateway after user explicitly confirms backup and chooses to add it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add --verify flag to verify saved private keys - Verification shows derived address and can match against expected - Update warning to emphasize this is the ONLY time key is displayed - Suggest password manager instead of writing down (key is long) - Remove hardware wallet suggestion - Add hint to use --verify for later addition to Gateway 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add detailed COMMANDS section with all flags explained - Add SECURITY NOTES section - Add ADDING WALLET TO GATEWAY MANUALLY section - Simplify --verify mode to just validate key and show address 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add --chain flag to specify solana (default) or ethereum - Support Ethereum key generation using ethers.js Wallet.createRandom() - Support Ethereum key verification (hex format with 0x prefix) - Update documentation header with both chain examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ncryption Add a dedicated environment variable (GATEWAY_WALLET_KEY) for wallet encryption that is separate from the server passphrase. This provides better security because: - Environment variables are not visible in `ps aux` (unlike --passphrase) - Not stored in shell history - Can be set separately from the shared server passphrase The system maintains backward compatibility by falling back to the existing passphrase if GATEWAY_WALLET_KEY is not set. Usage: export GATEWAY_WALLET_KEY=your-secret-key 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Commit e9920b0
Manual functional testing of CLI commands using pnpm
The only issue I found is when prompted to enter values, the input form is not immediately visible. The form only appears after typing a character and then pressing backspace ❌
|
rapcmia
previously approved these changes
Dec 19, 2025
nikspz
reviewed
Dec 19, 2025
Contributor
nikspz
left a comment
There was a problem hiding this comment.
- commit e9920b0
-
pnpm wallet:create --chain ethereum
- Need to install the following packages:
- ts-node@10.9.2
- proceed? yes
- failed ELIFECYCLE Command failed with exit code 1.
-
sudo apt-get install -y nodejs
-
pnpm install
-
pnpm wallet:create --chain ethereum ✅
- review created wallet address and private key successully
-
imported created private key successfully ✅
-
pnpm wallet:create -- --verify --chain ethereum ✅
-
pnpm wallet:create -- --chain ethereum✅- add as default ✅
- reviewed wallet added as default for ethereum
-
pnpm wallet:create -- --chain ethereum --no-add✅- review wallet created and not added to gateway
-
export GATEWAY_WALLET_KEY=Randompass
-
pnpm wallet:create -- --chain ethereum
-
wallet shown in gateway
-
unset GATEWAY_WALLET_KEY
-
restart and
-
gateway pnpm start --passphrase testpass --dev
-
Expected:
- Wallet cannot be decrypted
- Clear error in logs (e.g. “failed to decrypt wallet”)
-
Actual:
- no failed to decrypt wallet showed
-
- Add POST /wallet/create endpoint for server-side wallet generation - Add POST /wallet/show-private-key endpoint with explicit passphrase verification - Add POST /wallet/send endpoint for native and token transfers - Remove GATEWAY_WALLET_KEY env var, use passphrase only for wallet encryption - Register @fastify/sensible plugin for proper HTTP error responses - Add comprehensive tests for new wallet endpoints - Update Swagger examples to use configured default wallet addresses 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Detect token program by checking mint account owner and use the correct program ID (TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID) for ATA derivation and transfer instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Config values may be empty in CI environment, causing test failures. Use generated Solana keypair and fixed Ethereum test address instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Commit 0ab0660
Test gateway client-side scripts
Test new wallet endpoints
See attached for the test and gateway logs: 12232025a.zip |
- Create recipient's Associated Token Account (ATA) if it doesn't exist before SPL/Token2022 transfers - Add warning log when invalid passphrase is provided for show-private-key - Fixes InvalidAccountData error when sending tokens to wallets without ATAs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Commit 4e2b361
|
rapcmia
approved these changes
Dec 24, 2025
Contributor
rapcmia
left a comment
There was a problem hiding this comment.
Approved 1/2
- Test for solana chain ✅
nikspz
approved these changes
Dec 29, 2025
Contributor
nikspz
left a comment
There was a problem hiding this comment.
- ethereum
- POST /wallet/create ✅
- POST /wallet/show-private-key ✅
- invalid passphrase: ok
- {
"statusCode":401,
"error":"UnauthorizedError",
"message":"Invalid passphrase"
}
- {
- correct passphrase ✅
- showed pkey
- invalid passphrase: ok
- pnpm wallet:create -- --no-add ✅
- created wallet
- pnpm wallet:create -- --no-add --chain ethereum ✅
- created wallet
- pnpm wallet:create -- --verify --chain ethereum ✅
- returns correct address
- POST /wallet/send ✅
- curl -X'POST'
'http://localhost:15888/wallet/send'
-H'accept: application/json'
-H'Content-Type: application/json'
-d'{
"chain": "ethereum",
"network": "arbitrum",
"address": "0x08940dc9B5a19FAb9319b77C61DDA7B8067E6843",
"toAddress": "0xce8766734d2610e4cd0c58824a9FccED0c68af7A",
"amount": "0.1",
"token": "USDC"
}'- {
"signature":"0x723831cba95241751cb7e1e5ad8aae74eb073e172a0cf5e1a76934f21c98d789",
"status":1,
"amount":"0.1",
"token":"USDC",
"toAddress":"0xce8766734d2610e4cd0c58824a9FccED0c68af7A",
"fee":6.2159e-7
} - https://arbiscan.io/tx/0x723831cba95241751cb7e1e5ad8aae74eb073e172a0cf5e1a76934f21c98d789
- {
- curl -X'POST'
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.









Summary
Adds wallet management capabilities to Gateway:
New API Endpoints
POST /wallet/create
Create a new wallet server-side and store it encrypted in Gateway.
{ "chain": "solana", "setDefault": true }POST /wallet/show-private-key
Retrieve the private key for a wallet. Requires explicit passphrase verification for security.
{ "chain": "solana", "address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", "passphrase": "<gateway-passphrase>" }POST /wallet/send
Send native tokens (SOL/ETH) or SPL/ERC20 tokens to another address.
{ "chain": "solana", "network": "mainnet-beta", "address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", "toAddress": "<recipient-address>", "amount": "0.1", "token": "SOL" }Client-Side Wallet Generation Script
Security Model
Usage
Supported Chains
Files Changed
New Files
scripts/create-wallet.ts- Client-side wallet generation scriptsrc/wallet/routes/createWallet.ts- POST /wallet/create endpointsrc/wallet/routes/showPrivateKey.ts- POST /wallet/show-private-key endpointsrc/wallet/routes/sendTransaction.ts- POST /wallet/send endpointtest/wallet/wallet-new-routes.test.ts- Tests for new endpoints (21 test cases)Modified Files
package.json- Addedwallet:createnpm scriptsrc/services/config-manager-cert-passphrase.ts- Simplified to use passphrase onlysrc/wallet/schemas.ts- Added schemas for new endpointssrc/wallet/utils.ts- Added utility functions for new endpointssrc/wallet/wallet.routes.ts- Registered @fastify/sensible and new routesQA Manual Testing Instructions
Prerequisites
pnpm install)pnpm start --passphrase=test --dev)Test 1: Create wallet via API
Expected: Returns
{"address": "...", "chain": "solana"}Test 2: Show private key via API
Expected: Returns
{"address": "...", "chain": "solana", "privateKey": "..."}Test 3: Show private key with wrong passphrase
Expected: Returns 401 Unauthorized
Test 4: Send transaction via API
Expected: Returns transaction signature and status
Test 5: Generate wallet client-side
Expected: Displays address and private key with security warnings
Test 6: Verify private key
Expected: Prompts for private key and shows derived address
🤖 Generated with Claude Code