Skip to content

Commit 88384f7

Browse files
committed
log instead of throwing errors
1 parent 886148a commit 88384f7

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

packages/bitcore-wallet-client/src/lib/verifier.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ export class Verifier {
182182
return true;
183183
});
184184

185-
if (!creatorKeys)
186-
throw new Error('Missing creator key')
185+
if (!creatorKeys) {
186+
log.error('Missing creator key')
187+
return false;
188+
}
187189

188190
var creatorSigningPubKey;
189191

@@ -196,15 +198,17 @@ export class Verifier {
196198
txp.proposalSignaturePubKeySig,
197199
creatorKeys.xPubKey
198200
)
199-
)
200-
throw new Error('Invalid self-signed proposal signature')
201-
201+
) {
202+
log.error('Invalid self-signed proposal signature')
203+
return false;
204+
}
202205
creatorSigningPubKey = txp.proposalSignaturePubKey;
203206
} else {
204207
creatorSigningPubKey = creatorKeys.requestPubKey;
205208
}
206-
if (!creatorSigningPubKey)
207-
throw new Error('Missing creator signing key');
209+
if (!creatorSigningPubKey){
210+
log.error('Missing creator signing key');
211+
}
208212

209213
var hash;
210214
if (parseInt(txp.version) >= 3) {
@@ -222,11 +226,15 @@ export class Verifier {
222226
);
223227

224228
const verified = Utils.verifyMessage(hash, txp.proposalSignature, creatorSigningPubKey);
225-
if (!verified && !txp.prePublishRaw)
226-
throw new Error('Invalid proposal signature');
227-
228-
if (!verified && txp.prePublishRaw && !Utils.verifyMessage(txp.prePublishRaw, txp.proposalSignature, creatorSigningPubKey))
229-
throw new Error('Invalid refreshed proposal signature');
229+
if (!verified && !txp.prePublishRaw) {
230+
log.error('Invalid proposal signature');
231+
return false;
232+
}
233+
234+
if (!verified && txp.prePublishRaw && !Utils.verifyMessage(txp.prePublishRaw, txp.proposalSignature, creatorSigningPubKey)) {
235+
log.error('Invalid proposal signature');'Invalid refreshed proposal signature');
236+
return false
237+
}
230238

231239
if (Constants.UTXO_CHAINS.includes(chain)) {
232240
if (!this.checkAddress(credentials, txp.changeAddress)) {
@@ -289,9 +297,15 @@ export class Verifier {
289297
static checkTxProposal(credentials, txp, opts) {
290298
opts = opts || {};
291299

292-
if (!this.checkTxProposalSignature(credentials, txp)) return false;
300+
if (!this.checkTxProposalSignature(credentials, txp)) {
301+
log.error('Transaction proposal signature check failed');
302+
return false;
303+
}
293304

294-
if (opts.paypro && !this.checkPaypro(txp, opts.paypro)) return false;
305+
if (opts.paypro && !this.checkPaypro(txp, opts.paypro)) {
306+
log.error('Transaction proposal paypro check failed');
307+
return false;
308+
}
295309

296310
return true;
297311
}

0 commit comments

Comments
 (0)