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

Method getClient

packages/bitcore-cli/src/wallet.ts:94–122  ·  view source on GitHub ↗
(args: {
    mustBeNew?: boolean;
    mustExist?: boolean;
    doNotComplete?: boolean;
  })

Source from the content-addressed store, hash-verified

92 }
93
94 async getClient(args: {
95 mustBeNew?: boolean;
96 mustExist?: boolean;
97 doNotComplete?: boolean;
98 }): Promise<ClientType> {
99 const { mustBeNew, mustExist, doNotComplete } = args;
100
101 this.client = new Client({
102 baseUrl: url.resolve(this.host, '/bws/api'),
103 supportStaffWalletId: this.walletId
104 });
105
106 const exists = this.storage.exists();
107 if (exists && mustBeNew) {
108 Utils.die(`File "${this.filename}" already exists.`);
109 }
110 if (!exists) {
111 if (mustExist) {
112 Utils.die(`File "${this.filename}" not found.`);
113 }
114 return this.client;
115 }
116
117 _verbose && prompt.intro('Loading wallet');
118 const key = await this.load({ doNotComplete, allowCache: true });
119 _verbose && prompt.outro(`${!key ? 'Read-only ' : ''}Wallet loaded`);
120
121 return this.client;
122 }
123
124 async create(args: {
125 coin?: string;

Callers 4

createFromTssMethod · 0.95
registerMethod · 0.95
signTxpMethod · 0.95
signMessageMethod · 0.95

Calls 3

loadMethod · 0.95
dieMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected