@@ -4,8 +4,9 @@ import url from 'url';
44import { Key , type Network , TssKey } from '@bitpay-labs/bitcore-wallet-client' ;
55import * as prompt from '@clack/prompts' ;
66import { UserCancelled } from '../../errors' ;
7- import { getAddressType , getCopayerName , getPassword } from '../../prompts' ;
7+ import { getAddressType , getCopayerName , getPassword , promptKeyshareBackup } from '../../prompts' ;
88import { Utils } from '../../utils' ;
9+ import { exportWallet } from '../export' ;
910import type { CommonArgs } from '../../../types/cli' ;
1011
1112
@@ -26,7 +27,7 @@ export async function createThresholdSigWallet(
2627
2728 const copayerName = await getCopayerName ( ) ;
2829 const addressType = await getAddressType ( { chain, network, isMultiSig : false , isTss : true } ) ;
29- const password = await getPassword ( 'Enter a password for the wallet :' , { hidden : false } ) ;
30+ const password = await getPassword ( 'Lock your wallet with a password :' , { hidden : false } ) ;
3031
3132 let key ;
3233 if ( mnemonic ) {
@@ -46,6 +47,16 @@ export async function createThresholdSigWallet(
4647 const tssPassword = crypto . randomBytes ( 20 ) . toString ( 'hex' ) ;
4748 await tss . newKey ( { m, n, password : tssPassword } ) ;
4849
50+ prompt . note (
51+ 'Next, you will be asked to enter party 1\'s public key. Once you enter it, ' +
52+ 'a personal join code will be generated for you to give to them.' + os . EOL +
53+ 'To get their public key, party 1 should go ahead and start the join process ' +
54+ 'for their wallet by running bitcore-cli and selecting `Join Wallet`. Then they follow the ' +
55+ 'prompts until it tells them to share the public key with the session leader (you).' + os . EOL + os . EOL +
56+ 'Repeat this process for the other party members. Once all members have joined, the TSS ' +
57+ 'wallet creation process will finish.'
58+ ) ;
59+
4960 for ( let i = 1 ; i < n ; i ++ ) {
5061 const pubkey = await prompt . text ( {
5162 message : `Enter party ${ i } 's public key:` ,
@@ -133,7 +144,15 @@ export async function createThresholdSigWallet(
133144 } ) ;
134145 } ) ;
135146
147+
148+ // Keyshare backup
149+ const ok = await promptKeyshareBackup ( ) ;
150+ if ( ok ) {
151+ await exportWallet ( { wallet, opts : { ...opts , readonly : false } } ) ;
152+ }
153+
136154 return {
137- mnemonic : key . get ( password ) . mnemonic
155+ // TSS wallets cannot be restored from a mnemonic alone, so we return null here. All the wallet recovery information is in the keyshare backup file.
156+ mnemonic : null
138157 } ;
139158}
0 commit comments