Files
spaces-startos/startos/init/taskBtcAuth.ts
spacesops 172e3f63ac
Some checks are pending
Build Service / BuildPackage (push) Waiting to run
working
2026-05-14 05:39:56 -04:00

35 lines
867 B
TypeScript

import { storeJson } from '../fileModels/storeJson'
import { i18n } from '../i18n'
import { sdk } from '../sdk'
import {
BITCOIN_RPC_USER,
BITCOIND_PACKAGE_ID,
randomPassword,
} from '../utils'
export const taskBtcAuth = sdk.setupOnInit(async (effects) => {
const existing = await storeJson.read((s) => s.btcAuth).once()
if (existing) return
const username = BITCOIN_RPC_USER
const password = randomPassword()
await effects.action.createTask({
replayId: 'spaces-rpc-auth',
packageId: BITCOIND_PACKAGE_ID,
actionId: 'generate-rpc-dependent',
severity: 'critical',
reason: i18n('Spaces needs RPC credentials in Bitcoin'),
input: {
kind: 'partial',
value: { username, password },
},
})
await storeJson.merge(
effects,
{ btcAuth: { username, password } },
{ allowWriteAfterConst: true },
)
})