@solana/web3.js 1.87.6 → 1.88.0

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.
@@ -1124,6 +1124,8 @@ const VersionedMessage = {
1124
1124
  }
1125
1125
  };
1126
1126
 
1127
+ /** @internal */
1128
+
1127
1129
  /**
1128
1130
  * Transaction signature as base-58 encoded string
1129
1131
  */
@@ -1739,29 +1741,31 @@ class Transaction {
1739
1741
  *
1740
1742
  * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction
1741
1743
  */
1742
- verifySignatures(requireAllSignatures) {
1743
- return this._verifySignatures(this.serializeMessage(), requireAllSignatures === undefined ? true : requireAllSignatures);
1744
+ verifySignatures(requireAllSignatures = true) {
1745
+ const signatureErrors = this._getMessageSignednessErrors(this.serializeMessage(), requireAllSignatures);
1746
+ return !signatureErrors;
1744
1747
  }
1745
1748
 
1746
1749
  /**
1747
1750
  * @internal
1748
1751
  */
1749
- _verifySignatures(signData, requireAllSignatures) {
1752
+ _getMessageSignednessErrors(message, requireAllSignatures) {
1753
+ const errors = {};
1750
1754
  for (const {
1751
1755
  signature,
1752
1756
  publicKey
1753
1757
  } of this.signatures) {
1754
1758
  if (signature === null) {
1755
1759
  if (requireAllSignatures) {
1756
- return false;
1760
+ (errors.missing ||= []).push(publicKey);
1757
1761
  }
1758
1762
  } else {
1759
- if (!verify(signature, signData, publicKey.toBytes())) {
1760
- return false;
1763
+ if (!verify(signature, message, publicKey.toBytes())) {
1764
+ (errors.invalid ||= []).push(publicKey);
1761
1765
  }
1762
1766
  }
1763
1767
  }
1764
- return true;
1768
+ return errors.invalid || errors.missing ? errors : undefined;
1765
1769
  }
1766
1770
 
1767
1771
  /**
@@ -1780,8 +1784,18 @@ class Transaction {
1780
1784
  verifySignatures: true
1781
1785
  }, config);
1782
1786
  const signData = this.serializeMessage();
1783
- if (verifySignatures && !this._verifySignatures(signData, requireAllSignatures)) {
1784
- throw new Error('Signature verification failed');
1787
+ if (verifySignatures) {
1788
+ const sigErrors = this._getMessageSignednessErrors(signData, requireAllSignatures);
1789
+ if (sigErrors) {
1790
+ let errorMessage = 'Signature verification failed.';
1791
+ if (sigErrors.invalid) {
1792
+ errorMessage += `\nInvalid signature for public key${sigErrors.invalid.length === 1 ? '' : '(s)'} [\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\`].`;
1793
+ }
1794
+ if (sigErrors.missing) {
1795
+ errorMessage += `\nMissing signature for public key${sigErrors.missing.length === 1 ? '' : '(s)'} [\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\`].`;
1796
+ }
1797
+ throw new Error(errorMessage);
1798
+ }
1785
1799
  }
1786
1800
  return this._serialize(signData);
1787
1801
  }
@@ -9251,7 +9265,7 @@ class StakeProgram {
9251
9265
  if (custodianPubkey) {
9252
9266
  keys.push({
9253
9267
  pubkey: custodianPubkey,
9254
- isSigner: false,
9268
+ isSigner: true,
9255
9269
  isWritable: false
9256
9270
  });
9257
9271
  }
@@ -9299,7 +9313,7 @@ class StakeProgram {
9299
9313
  if (custodianPubkey) {
9300
9314
  keys.push({
9301
9315
  pubkey: custodianPubkey,
9302
- isSigner: false,
9316
+ isSigner: true,
9303
9317
  isWritable: false
9304
9318
  });
9305
9319
  }
@@ -9464,7 +9478,7 @@ class StakeProgram {
9464
9478
  if (custodianPubkey) {
9465
9479
  keys.push({
9466
9480
  pubkey: custodianPubkey,
9467
- isSigner: false,
9481
+ isSigner: true,
9468
9482
  isWritable: false
9469
9483
  });
9470
9484
  }