ecash-lib 4.14.0 → 4.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/script.ts CHANGED
@@ -399,6 +399,29 @@ export class Script {
399
399
  `Invalid multisig redeem script: expected ${numPubkeys} pubkeys, got ${pubkeys.length}`,
400
400
  );
401
401
  }
402
+ if (
403
+ !Number.isSafeInteger(numSignatures) ||
404
+ !Number.isSafeInteger(numPubkeys)
405
+ ) {
406
+ throw new Error(
407
+ `Invalid multisig redeem script: m and n must be safe integers (got m=${numSignatures}, n=${numPubkeys})`,
408
+ );
409
+ }
410
+ if (numSignatures < 1 || numPubkeys < 1) {
411
+ throw new Error(
412
+ `Invalid multisig redeem script: m and n must be >= 1 (got m=${numSignatures}, n=${numPubkeys})`,
413
+ );
414
+ }
415
+ if (numSignatures > numPubkeys) {
416
+ throw new Error(
417
+ `Invalid multisig redeem script: m must be <= n (got ${numSignatures} of ${numPubkeys})`,
418
+ );
419
+ }
420
+ if (numPubkeys > MAX_PUBKEYS_PER_MULTISIG) {
421
+ throw new Error(
422
+ `Invalid multisig redeem script: n must be <= ${MAX_PUBKEYS_PER_MULTISIG} (got ${numPubkeys})`,
423
+ );
424
+ }
402
425
  return { numSignatures, numPubkeys, pubkeys };
403
426
  }
404
427