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

Method create

packages/bitcore-cli/src/wallet.ts:124–167  ·  view source on GitHub ↗
(args: {
    coin?: string;
    chain: string;
    network: Network;
    copayerName: string;
    account: number;
    n: number;
    m?: number;
    mnemonic?: string;
    password?: string;
    addressType?: string;
    joinSecret?: string;
  })

Source from the content-addressed store, hash-verified

122 }
123
124 async create(args: {
125 coin?: string;
126 chain: string;
127 network: Network;
128 copayerName: string;
129 account: number;
130 n: number;
131 m?: number;
132 mnemonic?: string;
133 password?: string;
134 addressType?: string;
135 joinSecret?: string;
136 }) {
137 const { coin, chain, network, account, n, m, mnemonic, password, addressType, copayerName, joinSecret } = args;
138 let key: KeyType;
139 if (mnemonic) {
140 key = new Key({ seedType: 'mnemonic', seedData: mnemonic, password });
141 } else {
142 key = new Key({ seedType: 'new', password });
143 }
144 const credOpts = { coin, chain, network, account, n, m, mnemonic, password, addressType, copayerName, singleAddress: BWCUtils.isSingleAddressChain(chain) };
145 let credentials = key.createCredentials(password, credOpts);
146 this.client.fromObj(credentials);
147 this.#walletData = { key, credentials };
148 // Save here in case registering or joining fails (e.g. network issues)
149 await this.save();
150
151 let secret;
152 let joinedWalletName;
153 if (joinSecret) {
154 const wallet = await this.client.joinWallet(joinSecret, copayerName, { chain });
155 joinedWalletName = wallet.name;
156 } else {
157 secret = await this.register({ copayerName });
158 }
159 // Update credentials with joined/registered info (e.g. walletId, publicKeyRing, etc)
160 this.#walletData.credentials = this.client.credentials;
161 await this.save();
162 // this.load calls openWallet which completes the wallet by fetching any missing info
163 await this.load({ allowCache: true });
164
165 credentials = this.#walletData.credentials;
166 return { key, credentials, secret, joinedWalletName };
167 }
168
169 async createFromTss(args: {
170 key: TssKeyType;

Callers

nothing calls this directly

Calls 7

saveMethod · 0.95
registerMethod · 0.95
loadMethod · 0.95
isSingleAddressChainMethod · 0.80
createCredentialsMethod · 0.45
fromObjMethod · 0.45
joinWalletMethod · 0.45

Tested by

no test coverage detected