Signed, beneficiary-bount Monero subaddress enrollment
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
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,
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user