Durable, beneficiary-bound subaddress index reservation
This commit is contained in:
+15
-2
@@ -3,7 +3,8 @@ import { open, unlink, mkdir } from 'node:fs/promises';
|
||||
import { resolve, join } from 'node:path';
|
||||
import { postgresConfig } from '../server/market/postgres-config.ts';
|
||||
import { migrateCustody, grantCustodyRuntime, grantMoneroObserverRuntime,
|
||||
grantMoneroDepositCreditRuntime, grantMoneroDepositAllocatorRuntime, grantMoneroWithdrawalRuntime } from '../server/market/postgres-schema.ts';
|
||||
grantMoneroDepositCreditRuntime, grantMoneroDepositAllocatorRuntime, grantMoneroWithdrawalRuntime,
|
||||
grantPilotDepositReservationRuntime } from '../server/market/postgres-schema.ts';
|
||||
import { initializeMainnetCustodyIdentity, parseMainnetCustodianId } from '../server/market/mainnet-custody-identity.ts';
|
||||
import { importSqliteCustody } from '../server/market/custody-import.ts';
|
||||
import { PostgresCustody } from '../server/market/postgres-custody.ts';
|
||||
@@ -13,7 +14,8 @@ import { resolveCustodyIncident } from '../server/market/custody-incident.ts';
|
||||
import { loadMoneroDepositReviewApproval, loadMoneroDepositReviewPolicy } from '../server/market/monero-deposit-review-config.ts';
|
||||
import { assertCustodyDbActionAllowedOnNetwork, assertMainnetSchemaMigrationAcknowledged,
|
||||
assertMainnetCustodyOperationAcknowledged, assertPilotCustodyActionAllowed, assertPilotSchemaMigrationAcknowledged,
|
||||
assertPilotCustodyIdentityAcknowledged, parseCustodyDbArguments } from '../server/market/custody-db-args.ts';
|
||||
assertPilotCustodyIdentityAcknowledged, assertPilotReservationGrantAcknowledged,
|
||||
parseCustodyDbArguments } from '../server/market/custody-db-args.ts';
|
||||
import { prepareDepositCreditReview, postReviewedDepositPendingCredit, prepareDepositCreditReleaseReview,
|
||||
releaseReviewedDepositCredit, reconcileDepositCreditReorgHolds, prepareDepositReorgResolution,
|
||||
resolveReleasedDepositReorgHold, type DepositCreditApproval, type DepositCreditReleaseApproval,
|
||||
@@ -25,6 +27,7 @@ const depositActions = ['deposit-prepare-credit', 'deposit-stage-credit', 'depos
|
||||
'deposit-reconcile-holds', 'deposit-prepare-resolve-hold', 'deposit-resolve-hold'];
|
||||
const custodyActions = ['migrate', 'migrate-mainnet-schema', 'initialize-mainnet-custody-identity', 'migrate-pilot-schema',
|
||||
'initialize-pilot-custody-identity', 'grant-runtime', 'grant-monero-observer-runtime',
|
||||
'grant-pilot-deposit-reservation-runtime',
|
||||
'grant-monero-withdrawal-runtime',
|
||||
'grant-monero-deposit-allocator-runtime', 'grant-monero-credit-runtime',
|
||||
'import-sqlite', 'audit', 'resolve-integrity'];
|
||||
@@ -36,6 +39,7 @@ assertMainnetCustodyOperationAcknowledged(action, process.env.WIKIDECK_MAINNET_C
|
||||
assertPilotSchemaMigrationAcknowledged(action, process.env.WIKIDECK_PILOT_SCHEMA_MIGRATION);
|
||||
assertPilotCustodyIdentityAcknowledged(action, process.env.WIKIDECK_PILOT_CUSTODY_IDENTITY,
|
||||
process.env.WIKIDECK_PILOT_CUSTODY_OPERATIONS);
|
||||
assertPilotReservationGrantAcknowledged(action, process.env.WIKIDECK_PILOT_CUSTODY_OPERATIONS);
|
||||
if (action === 'initialize-mainnet-custody-identity' && process.env.WIKIDECK_MAINNET_CUSTODY_IDENTITY !== 'initialize-mainnet-custody-v1') {
|
||||
throw new Error('Mainnet custody identity initialization requires WIKIDECK_MAINNET_CUSTODY_IDENTITY=initialize-mainnet-custody-v1');
|
||||
}
|
||||
@@ -72,6 +76,15 @@ try {
|
||||
custodianId: identity.custodianId, activation: identity.activationStatus,
|
||||
deposits: 'disabled', withdrawals: 'disabled' }));
|
||||
}
|
||||
if (action === 'grant-pilot-deposit-reservation-runtime') {
|
||||
if (!IS_PILOT || process.env.WIKIDECK_PILOT_CUSTODY_OPERATIONS !== 'reservation-only-no-addresses' || extraArgument) {
|
||||
throw new Error('Pilot reservation grant requires the pilot profile, reservation-only acknowledgement, and one role name');
|
||||
}
|
||||
const identity = await pool.query('SELECT 1 FROM wk_custody.pilot_custody_identity WHERE singleton=1');
|
||||
if (!identity.rowCount) throw new Error('Initialize the separate pilot custody identity before granting reservation access');
|
||||
await grantPilotDepositReservationRuntime(pool, argument ?? '');
|
||||
console.log('Pilot durable index-reservation role granted; no Wallet-RPC address creation, credit, or withdrawal access.');
|
||||
}
|
||||
if (action === 'grant-runtime') { await grantCustodyRuntime(pool, argument ?? ''); console.log('Runtime grants applied; no credentials printed.'); }
|
||||
if (action === 'grant-monero-observer-runtime') {
|
||||
await grantMoneroObserverRuntime(pool, argument ?? '');
|
||||
|
||||
Reference in New Issue
Block a user