MCPcopy Index your code
hub / github.com/codeaashu/claude-code / saveX402PrivateKey

Function saveX402PrivateKey

src/services/x402/config.ts:121–141  ·  view source on GitHub ↗
(privateKeyHex: string)

Source from the content-addressed store, hash-verified

119 * file permissions (600).
120 */
121export function saveX402PrivateKey(privateKeyHex: string): string {
122 const keyHex = privateKeyHex.startsWith('0x')
123 ? privateKeyHex.slice(2)
124 : privateKeyHex
125
126 if (keyHex.length !== 64 || !/^[0-9a-fA-F]+$/.test(keyHex)) {
127 throw new Error('Invalid private key: must be 32 bytes (64 hex characters)')
128 }
129
130 const address = deriveAddress(keyHex)
131
132 saveGlobalConfig((config) => ({
133 ...config,
134 x402PrivateKey: `0x${keyHex}`,
135 }))
136
137 saveX402Config({ address })
138
139 logForDebugging(`[x402] Wallet configured: ${address}`)
140 return address
141}
142
143/** Removes the private key and disables x402 */
144export function removeX402PrivateKey(): void {

Callers 1

handleSetupFunction · 0.85

Calls 4

deriveAddressFunction · 0.85
saveGlobalConfigFunction · 0.85
saveX402ConfigFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected