Skip to content

Commit

Permalink
removes passphrase prompt from start command
Browse files Browse the repository at this point in the history
displays error message to user instead

removes logic plumbing passphrase through openDB to migrator
  • Loading branch information
hughy committed Nov 12, 2024
1 parent 92db57f commit 741db60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
31 changes: 10 additions & 21 deletions ironfish-cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
RpcUseTcpFlagKey,
} from '../flags'
import { ONE_FISH_IMAGE } from '../images'
import { inputPrompt } from '../ui'

export const ENABLE_TELEMETRY_CONFIG_KEY = 'enableTelemetry'
const DEFAULT_ACCOUNT_NAME = 'default'
Expand Down Expand Up @@ -230,26 +229,16 @@ export default class Start extends IronfishCommand {
}
this.log(` `)

let walletPassphrase: string | undefined

// eslint-disable-next-line no-constant-condition
while (true) {
try {
await NodeUtils.waitForOpen(node, () => this.closing, walletPassphrase)
break
} catch (e) {
if (e instanceof EncryptedWalletMigrationError) {
this.logger.info(e.message)
walletPassphrase = await inputPrompt(
'Enter your passphrase to unlock the wallet',
true,
{
password: true,
},
)
} else {
throw e
}
try {
await NodeUtils.waitForOpen(node, () => this.closing)
} catch (e) {
if (e instanceof EncryptedWalletMigrationError) {
this.logger.error(e.message)
this.logger.error(
'Run `ironfish migrations:start` to enter wallet passphrase and migrate wallet databases',
)
} else {
throw e
}
}

Expand Down
3 changes: 1 addition & 2 deletions ironfish/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,14 @@ export class FullNode {
return node
}

async openDB(walletPassphrase?: string): Promise<void> {
async openDB(): Promise<void> {
const migrate = this.config.get('databaseMigrate')
const initial = await this.migrator.isInitial()

if (migrate || initial) {
await this.migrator.migrate({
quiet: !migrate,
quietNoop: true,
walletPassphrase: walletPassphrase,
})
}

Expand Down
8 changes: 2 additions & 6 deletions ironfish/src/utils/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import { PromiseUtils } from './promise'
/**
* Try to open the node DB's and wait until they can be opened
*/
async function waitForOpen(
node: FullNode,
abort?: null | (() => boolean),
walletPassphrase?: string,
): Promise<void> {
async function waitForOpen(node: FullNode, abort?: null | (() => boolean)): Promise<void> {
let logged = false

while (!abort || !abort()) {
try {
await node.openDB(walletPassphrase)
await node.openDB()
return
} catch (e) {
if (e instanceof DatabaseIsLockedError) {
Expand Down

0 comments on commit 741db60

Please sign in to comment.