Skip to content

Commit 0f0d71f

Browse files
authored
adds ledger flag to 'wallet:multisig:participant' (#5712)
* adds ledger flag to 'wallet:multisig:participant' supports reading identity from ledger and displaying on CLI * avoids checking for wallet encryption when using ledger flag
1 parent f7a99d8 commit 0f0d71f

File tree

1 file changed

+49
-28
lines changed
  • ironfish-cli/src/commands/wallet/multisig/participant

1 file changed

+49
-28
lines changed

ironfish-cli/src/commands/wallet/multisig/participant/index.ts

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,78 @@ import { Flags } from '@oclif/core'
55
import inquirer from 'inquirer'
66
import { IronfishCommand } from '../../../../command'
77
import { RemoteFlags } from '../../../../flags'
8+
import { LedgerMultiSigner } from '../../../../ledger'
89
import * as ui from '../../../../ui'
910

1011
export class MultisigIdentity extends IronfishCommand {
11-
static description = `Retrieve a multisig participant identity from a name`
12+
static description = `Retrieve a multisig participant identity`
1213

1314
static flags = {
1415
...RemoteFlags,
1516
name: Flags.string({
1617
char: 'n',
1718
description: 'Name of the participant identity',
1819
}),
20+
ledger: Flags.boolean({
21+
default: false,
22+
description: 'Retrieve participant identity from a ledger device',
23+
exclusive: ['name'],
24+
}),
1925
}
2026

2127
async start(): Promise<void> {
2228
const { flags } = await this.parse(MultisigIdentity)
2329

24-
const client = await this.connectRpc()
25-
await ui.checkWalletUnlocked(client)
30+
if (flags.ledger) {
31+
const ledger = new LedgerMultiSigner()
2632

27-
if (flags.name) {
28-
const response = await client.wallet.multisig.getIdentity({ name: flags.name })
33+
const identity = (
34+
await ui.ledger({
35+
ledger,
36+
message: 'Getting Ledger Identity',
37+
action: () => ledger.dkgGetIdentity(0),
38+
})
39+
).toString('hex')
2940

3041
this.log('Identity:')
31-
this.log(response.content.identity)
42+
this.log(identity)
3243
} else {
33-
const response = await client.wallet.multisig.getIdentities()
44+
const client = await this.connectRpc()
45+
await ui.checkWalletUnlocked(client)
3446

35-
const choices = []
36-
for (const { name, identity } of response.content.identities) {
37-
choices.push({
38-
name,
39-
value: identity,
40-
})
41-
}
47+
if (flags.name) {
48+
const response = await client.wallet.multisig.getIdentity({ name: flags.name })
4249

43-
// sort identities by name
44-
choices.sort((a, b) => a.name.localeCompare(b.name))
50+
this.log('Identity:')
51+
this.log(response.content.identity)
52+
} else {
53+
const response = await client.wallet.multisig.getIdentities()
4554

46-
const selection = await inquirer.prompt<{
47-
identity: string
48-
}>([
49-
{
50-
name: 'identity',
51-
message: 'Select participant name to view identity',
52-
type: 'list',
53-
choices,
54-
},
55-
])
55+
const choices = []
56+
for (const { name, identity } of response.content.identities) {
57+
choices.push({
58+
name,
59+
value: identity,
60+
})
61+
}
5662

57-
this.log('Identity:')
58-
this.log(selection.identity)
63+
// sort identities by name
64+
choices.sort((a, b) => a.name.localeCompare(b.name))
65+
66+
const selection = await inquirer.prompt<{
67+
identity: string
68+
}>([
69+
{
70+
name: 'identity',
71+
message: 'Select participant name to view identity',
72+
type: 'list',
73+
choices,
74+
},
75+
])
76+
77+
this.log('Identity:')
78+
this.log(selection.identity)
79+
}
5980
}
6081
}
6182
}

0 commit comments

Comments
 (0)