(args: CommonArgs<{ mnemonic?: string }>)
| 6 | import type { CommonArgs } from '../../../types/cli'; |
| 7 | |
| 8 | export async function joinMultiSigWallet(args: CommonArgs<{ mnemonic?: string }>) { |
| 9 | const { wallet, opts } = args; |
| 10 | const { verbose, mnemonic } = opts; |
| 11 | |
| 12 | const joinSecret = await prompt.text({ |
| 13 | message: 'Enter the secret to join the wallet:', |
| 14 | validate: (input) => input?.trim() ? null : 'Secret cannot be empty.', |
| 15 | }); |
| 16 | if (prompt.isCancel(joinSecret)) { |
| 17 | throw new UserCancelled(); |
| 18 | } |
| 19 | |
| 20 | const parsed = BWC.parseSecret(joinSecret.trim()); |
| 21 | const { |
| 22 | coin: chain, |
| 23 | network |
| 24 | } = parsed; |
| 25 | |
| 26 | const copayerName = await getCopayerName(); |
| 27 | const password = await getPassword('Lock your wallet with a password:', { hidden: false }); |
| 28 | const { key, joinedWalletName } = await wallet.create({ chain, network, account: 0, n: 2, m: 1, password, mnemonic, copayerName, joinSecret }); // n gets overwritten |
| 29 | |
| 30 | prompt.log.success(Utils.colorText(`Wallet joined: ${joinedWalletName}`, 'green')); |
| 31 | verbose && prompt.log.step(`Wallet file saved to: ${Utils.colorText(wallet.filename, 'blue')}`); |
| 32 | |
| 33 | return { |
| 34 | mnemonic: key.get(password).mnemonic, |
| 35 | }; |
| 36 | }; |
no test coverage detected