34 lines
1.4 KiB
TypeScript
Executable File
34 lines
1.4 KiB
TypeScript
Executable File
import { z } from 'zod';
|
|
|
|
const hex64 = z.string().regex(/^[a-f0-9]{64}$/);
|
|
const uuid = z.string().uuid();
|
|
const network = z.enum(['wikideck-randomx-mainnet-1', 'wikideck-randomx-testnet-6']);
|
|
|
|
/** Wallet-signed request to allocate the caller's own immutable Monero subaddress. */
|
|
export const moneroDepositAddressRequestSchema = z.object({
|
|
version: z.literal(1),
|
|
network,
|
|
chainId: hex64,
|
|
custodianId: uuid,
|
|
actor: hex64,
|
|
publicKey: z.string().min(1).max(256),
|
|
requestId: uuid,
|
|
walletGenerationId: uuid,
|
|
walletFingerprint: hex64,
|
|
accountIndex: z.number().int().min(0).max(0xffff_ffff).safe(),
|
|
expiresAt: z.number().int().nonnegative().safe(),
|
|
signature: z.string().min(1).max(256),
|
|
}).strict();
|
|
|
|
export type MoneroDepositAddressRequest = z.infer<typeof moneroDepositAddressRequestSchema>;
|
|
export type MoneroDepositAddressRequestUnsigned = Omit<MoneroDepositAddressRequest, 'signature'>;
|
|
|
|
/** Domain-separated, canonical terms for requesting one beneficiary-bound deposit address. */
|
|
export function moneroDepositAddressMessage(request: MoneroDepositAddressRequestUnsigned): string {
|
|
return JSON.stringify([
|
|
'wikideck-monero-deposit-address-v1', request.version, request.network, request.chainId,
|
|
request.custodianId, request.actor, request.publicKey, request.requestId,
|
|
request.walletGenerationId, request.walletFingerprint, request.accountIndex, request.expiresAt,
|
|
]);
|
|
}
|