Skip to content

Commit 83dce4f

Browse files
authored
makes participantName and ledger flags exclusive in dkg (#5742)
when using a ledger device the user should not need to enter a participant name or select the participant from those in the walletDB since the identity should be read from the ledger device prompts the user for an account name in round3 if using a ledger
1 parent f4dbb38 commit 83dce4f

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class DkgRound1Command extends IronfishCommand {
3030
ledger: Flags.boolean({
3131
default: false,
3232
description: 'Perform operation with a ledger device',
33+
exclusive: ['participantName'],
3334
}),
3435
}
3536

@@ -39,11 +40,6 @@ export class DkgRound1Command extends IronfishCommand {
3940
const client = await this.connectRpc()
4041
await ui.checkWalletUnlocked(client)
4142

42-
let participantName = flags.participantName
43-
if (!participantName) {
44-
participantName = await ui.multisigSecretPrompt(client)
45-
}
46-
4743
let identities = flags.identity
4844
if (!identities || identities.length < 2) {
4945
const input = await ui.longPrompt(
@@ -74,6 +70,11 @@ export class DkgRound1Command extends IronfishCommand {
7470
return
7571
}
7672

73+
let participantName = flags.participantName
74+
if (!participantName) {
75+
participantName = await ui.multisigSecretPrompt(client)
76+
}
77+
7778
const response = await client.wallet.multisig.dkg.round1({
7879
participantName,
7980
participants: identities.map((identity) => ({ identity })),

ironfish-cli/src/commands/wallet/multisig/dkg/round2.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class DkgRound2Command extends IronfishCommand {
3030
ledger: Flags.boolean({
3131
default: false,
3232
description: 'Perform operation with a ledger device',
33+
exclusive: ['participantName'],
3334
}),
3435
}
3536

@@ -39,17 +40,9 @@ export class DkgRound2Command extends IronfishCommand {
3940
const client = await this.connectRpc()
4041
await ui.checkWalletUnlocked(client)
4142

42-
let participantName = flags.participantName
43-
if (!participantName) {
44-
participantName = await ui.multisigSecretPrompt(client)
45-
}
46-
4743
let round1SecretPackage = flags.round1SecretPackage
4844
if (!round1SecretPackage) {
49-
round1SecretPackage = await ui.inputPrompt(
50-
`Enter the round 1 secret package for participant ${participantName}`,
51-
true,
52-
)
45+
round1SecretPackage = await ui.inputPrompt('Enter your round 1 secret package', true)
5346
}
5447

5548
let round1PublicPackages = flags.round1PublicPackages
@@ -73,6 +66,11 @@ export class DkgRound2Command extends IronfishCommand {
7366
return
7467
}
7568

69+
let participantName = flags.participantName
70+
if (!participantName) {
71+
participantName = await ui.multisigSecretPrompt(client)
72+
}
73+
7674
const response = await client.wallet.multisig.dkg.round2({
7775
participantName,
7876
round1SecretPackage,

ironfish-cli/src/commands/wallet/multisig/dkg/round3.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class DkgRound3Command extends IronfishCommand {
5151
ledger: Flags.boolean({
5252
default: false,
5353
description: 'Perform operation with a ledger device',
54+
exclusive: ['participantName'],
5455
}),
5556
createdAt: Flags.integer({
5657
description:
@@ -64,15 +65,10 @@ export class DkgRound3Command extends IronfishCommand {
6465
const client = await this.connectRpc()
6566
await ui.checkWalletUnlocked(client)
6667

67-
let participantName = flags.participantName
68-
if (!participantName) {
69-
participantName = await ui.multisigSecretPrompt(client)
70-
}
71-
7268
let round2SecretPackage = flags.round2SecretPackage
7369
if (!round2SecretPackage) {
7470
round2SecretPackage = await ui.inputPrompt(
75-
`Enter the round 2 encrypted secret package for participant ${participantName}`,
71+
'Enter your round 2 encrypted secret package',
7672
true,
7773
)
7874
}
@@ -127,9 +123,14 @@ export class DkgRound3Command extends IronfishCommand {
127123
}
128124

129125
if (flags.ledger) {
126+
let accountName = flags.accountName
127+
if (!accountName) {
128+
accountName = await ui.inputPrompt('Enter a name for the account', true)
129+
}
130+
130131
await this.performRound3WithLedger(
131132
client,
132-
participantName,
133+
accountName,
133134
round1PublicPackages,
134135
round2PublicPackages,
135136
round2SecretPackage,
@@ -138,6 +139,11 @@ export class DkgRound3Command extends IronfishCommand {
138139
return
139140
}
140141

142+
let participantName = flags.participantName
143+
if (!participantName) {
144+
participantName = await ui.multisigSecretPrompt(client)
145+
}
146+
141147
const response = await client.wallet.multisig.dkg.round3({
142148
participantName,
143149
accountName: flags.accountName,
@@ -155,7 +161,7 @@ export class DkgRound3Command extends IronfishCommand {
155161

156162
async performRound3WithLedger(
157163
client: RpcClient,
158-
participantName: string,
164+
accountName: string,
159165
round1PublicPackagesStr: string[],
160166
round2PublicPackagesStr: string[],
161167
round2SecretPackage: string,
@@ -238,7 +244,7 @@ export class DkgRound3Command extends IronfishCommand {
238244
identity,
239245
},
240246
version: ACCOUNT_SCHEMA_VERSION,
241-
name: participantName,
247+
name: accountName,
242248
spendingKey: null,
243249
createdAt: null,
244250
ledger: true,
@@ -249,7 +255,7 @@ export class DkgRound3Command extends IronfishCommand {
249255
client,
250256
encodeAccountImport(accountImport, AccountFormat.Base64Json),
251257
this.logger,
252-
participantName,
258+
accountName,
253259
accountCreatedAt,
254260
)
255261

0 commit comments

Comments
 (0)