diff --git a/ironfish-cli/src/commands/wallet/multisig/create-signature-share.ts b/ironfish-cli/src/commands/wallet/multisig/create-signature-share.ts index d6c0eab63e..9e64e59701 100644 --- a/ironfish-cli/src/commands/wallet/multisig/create-signature-share.ts +++ b/ironfish-cli/src/commands/wallet/multisig/create-signature-share.ts @@ -5,6 +5,7 @@ import { Flags } from '@oclif/core' import { IronfishCommand } from '../../../command' import { RemoteFlags } from '../../../flags' +import { largePrompt } from '../../../utils/longPrompt' export class CreateSignatureShareCommand extends IronfishCommand { static description = `Creates a signature share for a participant for a given transaction` @@ -20,25 +21,35 @@ export class CreateSignatureShareCommand extends IronfishCommand { unsignedTransaction: Flags.string({ char: 'u', description: 'The unsigned transaction for which the signature share will be created', - required: true, + required: false, }), signingPackage: Flags.string({ char: 's', description: 'The signing package for which the signature share will be created', - required: true, + required: false, }), } async start(): Promise { const { flags } = await this.parse(CreateSignatureShareCommand) + let unsignedTransaction = flags.unsignedTransaction?.trim() + let signingPackage = flags.signingPackage?.trim() + + if (!unsignedTransaction) { + unsignedTransaction = await largePrompt('Enter the unsigned transaction: ') + } + + if (!signingPackage) { + signingPackage = await largePrompt('Enter the signing package: ') + } const client = await this.sdk.connectRpc() // TODO(andrea): use flags.transaction to create commiment when we incorportate deterministic nonces // set required to true as well const signatureShareResponse = await client.wallet.multisig.createSignatureShare({ account: flags.account, - unsignedTransaction: flags.unsignedTransaction, - signingPackage: flags.signingPackage, + unsignedTransaction, + signingPackage, seed: 0, }) diff --git a/ironfish-cli/src/utils/longPrompt.ts b/ironfish-cli/src/utils/longPrompt.ts new file mode 100644 index 0000000000..bd50d9ad3c --- /dev/null +++ b/ironfish-cli/src/utils/longPrompt.ts @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import readline from 'readline' + +// Most effective way to take in a large textual prompt input without affecting UX +export function largePrompt(question: string): Promise { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }) + + return new Promise((resolve) => { + rl.question(question, (answer) => { + rl.close() + resolve(answer.trim()) + }) + }) +}