diff --git a/packages/bitcore-wallet-client/src/lib/api.ts b/packages/bitcore-wallet-client/src/lib/api.ts index 191e0ad8399..40c76e79d0e 100644 --- a/packages/bitcore-wallet-client/src/lib/api.ts +++ b/packages/bitcore-wallet-client/src/lib/api.ts @@ -580,6 +580,7 @@ export class API extends EventEmitter { if (this.credentials.walletPrivKey) { if (!Verifier.checkCopayers(this.credentials, wallet.copayers)) { + log.error('Copayer verification falied on openWallet'); return cb(new Errors.SERVER_COMPROMISED()); } } else { @@ -1457,6 +1458,7 @@ export class API extends EventEmitter { this.credentials.sharedEncryptingKey ) ) { + log.error('Transaction proposal verification falied on createTxProposal'); return cb(new Errors.SERVER_COMPROMISED()); } @@ -1520,6 +1522,7 @@ export class API extends EventEmitter { if (err) return cb(err); if (!Verifier.checkAddress(this.credentials, address)) { + log.error('Address verification falied on createAddress'); return cb(new Errors.SERVER_COMPROMISED()); } @@ -1555,7 +1558,10 @@ export class API extends EventEmitter { if (!opts.doNotVerify) { const fake = (addresses || []).some(address => !Verifier.checkAddress(this.credentials, address)); - if (fake) return cb(new Errors.SERVER_COMPROMISED()); + if (fake) { + log.error('Address verification falied on getMainAddresses'); + return cb(new Errors.SERVER_COMPROMISED()); + } } return cb(null, addresses); }); @@ -1632,11 +1638,14 @@ export class API extends EventEmitter { return acb(isLegit); }) .catch(err => { - return acb(err); + return cb(err); }); }, isLegit => { - if (!isLegit) return cb(new Errors.SERVER_COMPROMISED()); + if (!isLegit) { + log.error('Transaction proposal verification falied on getTxProposals'); + return cb(new Errors.SERVER_COMPROMISED()); + } var result; if (opts.forAirGapped) { @@ -1724,7 +1733,10 @@ export class API extends EventEmitter { this.getPayProV2(txp) .then(paypro => { const isLegit = Verifier.checkTxProposal(this.credentials, txp, { paypro }); - if (!isLegit) return cb(new Errors.SERVER_COMPROMISED()); + if (!isLegit) { + log.error('Transaction proposal verification falied on pushSignatures'); + return cb(new Errors.SERVER_COMPROMISED()); + } baseUrl = baseUrl || '/v2/txproposals/'; const url = baseUrl + txp.id + '/signatures/'; @@ -2924,6 +2936,7 @@ export class API extends EventEmitter { if (credentials.walletPrivKey) { if (!Verifier.checkCopayers(credentials, wallet.copayers)) { + log.error('Copayer verification falied on serverAssistedImport'); return cb2(null, new Errors.SERVER_COMPROMISED()); } } else { diff --git a/packages/bitcore-wallet-client/src/lib/verifier.ts b/packages/bitcore-wallet-client/src/lib/verifier.ts index 0890b598e30..2b80b05369a 100644 --- a/packages/bitcore-wallet-client/src/lib/verifier.ts +++ b/packages/bitcore-wallet-client/src/lib/verifier.ts @@ -182,7 +182,11 @@ export class Verifier { return true; }); - if (!creatorKeys) return false; + if (!creatorKeys) { + log.error('Missing creator key') + return false; + } + var creatorSigningPubKey; // If the txp using a selfsigned pub key? @@ -194,14 +198,17 @@ export class Verifier { txp.proposalSignaturePubKeySig, creatorKeys.xPubKey ) - ) + ) { + log.error('Invalid self-signed proposal signature') return false; - + } creatorSigningPubKey = txp.proposalSignaturePubKey; } else { creatorSigningPubKey = creatorKeys.requestPubKey; } - if (!creatorSigningPubKey) return false; + if (!creatorSigningPubKey) { + log.error('Missing creator signing key'); + } var hash; if (parseInt(txp.version) >= 3) { @@ -219,11 +226,15 @@ export class Verifier { ); const verified = Utils.verifyMessage(hash, txp.proposalSignature, creatorSigningPubKey); - if (!verified && !txp.prePublishRaw) - return false; - - if (!verified && txp.prePublishRaw && !Utils.verifyMessage(txp.prePublishRaw, txp.proposalSignature, creatorSigningPubKey)) - return false; + if (!verified && !txp.prePublishRaw) { + log.error('Invalid proposal signature'); + return false; + } + + if (!verified && txp.prePublishRaw && !Utils.verifyMessage(txp.prePublishRaw, txp.proposalSignature, creatorSigningPubKey)) { + log.error('Invalid refreshed proposal signature'); + return false + } if (Constants.UTXO_CHAINS.includes(chain)) { if (!this.checkAddress(credentials, txp.changeAddress)) { @@ -286,9 +297,15 @@ export class Verifier { static checkTxProposal(credentials, txp, opts) { opts = opts || {}; - if (!this.checkTxProposalSignature(credentials, txp)) return false; + if (!this.checkTxProposalSignature(credentials, txp)) { + log.error('Transaction proposal signature check failed'); + return false; + } - if (opts.paypro && !this.checkPaypro(txp, opts.paypro)) return false; + if (opts.paypro && !this.checkPaypro(txp, opts.paypro)) { + log.error('Transaction proposal paypro check failed'); + return false; + } return true; }