-
-
Notifications
You must be signed in to change notification settings - Fork 263
feat: add wallet generation script and wallet API endpoints #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
- 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 <[email protected]>
- 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 <[email protected]>
- 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 <[email protected]>
…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 <[email protected]>
|
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 ❌
|
nikspz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- commit e9920b0
-
pnpm wallet:create --chain ethereum
- Need to install the following packages:
- [email protected]
- 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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
|
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 <[email protected]>
|
Commit 4e2b361
|
rapcmia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved 1/2
- Test for solana chain ✅
nikspz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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'









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