@@ -5,57 +5,78 @@ import { Flags } from '@oclif/core'
5
5
import inquirer from 'inquirer'
6
6
import { IronfishCommand } from '../../../../command'
7
7
import { RemoteFlags } from '../../../../flags'
8
+ import { LedgerMultiSigner } from '../../../../ledger'
8
9
import * as ui from '../../../../ui'
9
10
10
11
export class MultisigIdentity extends IronfishCommand {
11
- static description = `Retrieve a multisig participant identity from a name `
12
+ static description = `Retrieve a multisig participant identity`
12
13
13
14
static flags = {
14
15
...RemoteFlags ,
15
16
name : Flags . string ( {
16
17
char : 'n' ,
17
18
description : 'Name of the participant identity' ,
18
19
} ) ,
20
+ ledger : Flags . boolean ( {
21
+ default : false ,
22
+ description : 'Retrieve participant identity from a ledger device' ,
23
+ exclusive : [ 'name' ] ,
24
+ } ) ,
19
25
}
20
26
21
27
async start ( ) : Promise < void > {
22
28
const { flags } = await this . parse ( MultisigIdentity )
23
29
24
- const client = await this . connectRpc ( )
25
- await ui . checkWalletUnlocked ( client )
30
+ if ( flags . ledger ) {
31
+ const ledger = new LedgerMultiSigner ( )
26
32
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' )
29
40
30
41
this . log ( 'Identity:' )
31
- this . log ( response . content . identity )
42
+ this . log ( identity )
32
43
} else {
33
- const response = await client . wallet . multisig . getIdentities ( )
44
+ const client = await this . connectRpc ( )
45
+ await ui . checkWalletUnlocked ( client )
34
46
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 } )
42
49
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 ( )
45
54
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
+ }
56
62
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
+ }
59
80
}
60
81
}
61
82
}
0 commit comments