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

Method signMessage

packages/bitcore-cli/src/wallet.ts:614–635  ·  view source on GitHub ↗
(args: {
    message: string;
    derivationPath: string;
    encoding?: BufferEncoding | 'base58';
  })

Source from the content-addressed store, hash-verified

612 }
613
614 async signMessage(args: {
615 message: string;
616 derivationPath: string;
617 encoding?: BufferEncoding | 'base58';
618 }): Promise<CWCTypes.Message.ISignedMessage> {
619 const { message, derivationPath, encoding } = args;
620
621 if (!this.client) {
622 await this.getClient({ mustExist: true });
623 }
624 const password = await this.getPasswordWithRetry();
625 const chain = this.client.credentials.chain;
626
627 if (this.#walletData.key instanceof TssKey.TssKey) {
628 const messageHash = Message.getMessageHash({ chain, message }) as Buffer;
629 return this._signMessageWithTss({ messageHash, derivationPath, password, encoding });
630 }
631
632 const hdPrivateKey = this.#walletData.key.get(password).xPrivKey;
633 const fullDerivationPath = this.client.getRootPath() + derivationPath.replace('m', '');
634 return Message.signMessageWithPath({ chain, message, derivationPath: fullDerivationPath, hdPrivateKey, encoding });
635 }
636
637 async _signMessageWithTss(args: {
638 messageHash: Buffer;

Callers

nothing calls this directly

Calls 7

getClientMethod · 0.95
getPasswordWithRetryMethod · 0.95
_signMessageWithTssMethod · 0.95
getMessageHashMethod · 0.65
getMethod · 0.65
signMessageWithPathMethod · 0.65
getRootPathMethod · 0.45

Tested by

no test coverage detected