MCPcopy Create free account
hub / github.com/bitpay/bitcore / joinMultiSigWallet

Function joinMultiSigWallet

packages/bitcore-cli/src/commands/join/joinMultiSig.ts:8–36  ·  view source on GitHub ↗
(args: CommonArgs<{ mnemonic?: string }>)

Source from the content-addressed store, hash-verified

6import type { CommonArgs } from '../../../types/cli';
7
8export 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};

Callers 1

joinWalletFunction · 0.90

Calls 6

getCopayerNameFunction · 0.90
getPasswordFunction · 0.90
parseSecretMethod · 0.80
colorTextMethod · 0.80
createMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected