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

Method register

packages/bitcore-cli/src/wallet.ts:196–229  ·  view source on GitHub ↗
(args: { copayerName: string })

Source from the content-addressed store, hash-verified

194 }
195
196 async register(args: { copayerName: string }) {
197 if (!this.client) {
198 await this.getClient({ mustExist: true });
199 }
200 const { chain, coin, network, m, n, addressType, tssKeyId } = this.client.credentials;
201 if (coin && coin !== chain) {
202 // temporarily set it to chain for registration.
203 // coin != chain for token wallets exported from the app.
204 this.client.credentials.coin = chain;
205 }
206
207 if (tssKeyId) {
208 // This function will only register the wallet as a single-sig (non-TSS) wallet (BAD!).
209 // Importing a TSS wallet to a new server will need to create a tsskeygen Mongo document
210 // on the server and include the tssKeyId in the wallet registration process.
211 throw new Error('This wallet appears to be a TSS wallet. Registering an existing TSS wallet on a different server is not yet supported.');
212 }
213
214 const { secret } = await this.client.createWallet(
215 this.name,
216 args.copayerName,
217 m,
218 n,
219 {
220 chain,
221 network: network as Network,
222 ...Utils.getSegwitInfo(addressType)
223 }
224 );
225 if (coin) {
226 this.client.credentials.coin = coin; // change it back.
227 }
228 return secret as string | undefined;
229 }
230
231 async load(opts?: { doNotComplete?: boolean; allowCache?: boolean }) {
232 const { doNotComplete, allowCache } = opts || {};

Callers 1

createMethod · 0.95

Calls 3

getClientMethod · 0.95
getSegwitInfoMethod · 0.80
createWalletMethod · 0.65

Tested by

no test coverage detected