Skip to content

Commit 0691c63

Browse files
authored
handles Ledger 'invalid dkg status' errors (#5667)
if a user attempts to sign a transaction, but their ledger app doesn't have any multisig keys persisted, then the signing operation will fail with an 'invalid dkg status' error. this can happen if the user reinstalls the app or if the user starts creating a new account on the device using bkg, but doesn't finish the only ways to recover from this error are to restore an encrypted backup to the device, or to create a new multisig account using the device. since the error shows up during signing, we can infer that the user expects to have an account on the device and should be instructed to restore the backup
1 parent 6bdd3ec commit 0691c63

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

ironfish-cli/src/ledger/ledger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const IronfishLedgerStatusCodes = {
2626
PANIC: 0xe000,
2727
EXPERT_MODE_REQUIRED: 0x6984,
2828
DKG_EXPERT_MODE_REQUIRED: 0xb027,
29+
INVALID_DKG_STATUS: 0xb022,
2930
}
3031

3132
export class Ledger {
@@ -73,6 +74,8 @@ export class Ledger {
7374
throw new LedgerPanicError()
7475
} else if (error.returnCode === IronfishLedgerStatusCodes.GP_AUTH_FAILED) {
7576
throw new LedgerGPAuthFailed()
77+
} else if (error.returnCode === IronfishLedgerStatusCodes.INVALID_DKG_STATUS) {
78+
throw new LedgerInvalidDkgStatusError()
7679
} else if (
7780
error.returnCode === IronfishLedgerStatusCodes.EXPERT_MODE_REQUIRED ||
7881
error.returnCode === IronfishLedgerStatusCodes.DKG_EXPERT_MODE_REQUIRED
@@ -191,3 +194,4 @@ export class LedgerActionRejected extends LedgerError {}
191194
export class LedgerInvalidTxHash extends LedgerError {}
192195
export class LedgerPanicError extends LedgerError {}
193196
export class LedgerExpertModeError extends LedgerError {}
197+
export class LedgerInvalidDkgStatusError extends LedgerError {}

ironfish-cli/src/ui/ledger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
LedgerDeviceLockedError,
2222
LedgerExpertModeError,
2323
LedgerGPAuthFailed,
24+
LedgerInvalidDkgStatusError,
2425
LedgerPanicError,
2526
LedgerPortIsBusyError,
2627
LedgerSingleSigner,
@@ -103,6 +104,12 @@ export async function ledger<TResult>({
103104
if (!wasRunning) {
104105
ux.action.start(message)
105106
}
107+
} else if (e instanceof LedgerInvalidDkgStatusError) {
108+
ux.action.stop('Ironfish DKG Ledger App does not have any multisig keys!')
109+
ux.stdout(
110+
'Use `wallet:multisig:ledger:restore` to restore an encrypted backup to your Ledger',
111+
)
112+
ux.exit(1)
106113
} else if (e instanceof LedgerActionRejected) {
107114
ux.action.status = 'User Rejected Ledger Request!'
108115
ux.stdout('User Rejected Ledger Request!')

0 commit comments

Comments
 (0)