@alephium/web3 0.45.0 → 1.0.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.
@@ -31,6 +31,7 @@ const utils_1 = require("../utils");
31
31
  const lockup_script_codec_1 = require("../codec/lockup-script-codec");
32
32
  const codec_1 = require("../codec");
33
33
  const ec = new elliptic_1.ec('secp256k1');
34
+ const PublicKeyHashSize = 32;
34
35
  var AddressType;
35
36
  (function (AddressType) {
36
37
  AddressType[AddressType["P2PKH"] = 0] = "P2PKH";
@@ -63,10 +64,14 @@ function decodeAndValidateAddress(address) {
63
64
  }
64
65
  const n = multisig.publicKeyHashes.value.length;
65
66
  const m = codec_1.compactSignedIntCodec.toI32(multisig.m);
66
- if (n < m) {
67
+ if (n < m || m <= 0) {
67
68
  throw new Error(`Invalid multisig address, n: ${n}, m: ${m}`);
68
69
  }
69
- return decoded;
70
+ const encodedNSize = codec_1.compactSignedIntCodec.encodeI32(n).length;
71
+ const encodedMSize = multisig.m.rest.length + 1;
72
+ const size = encodedNSize + PublicKeyHashSize * n + encodedMSize + 1; // 1 for the P2MPKH prefix
73
+ if (decoded.length === size)
74
+ return decoded;
70
75
  }
71
76
  else if (addressType === AddressType.P2PKH || addressType === AddressType.P2SH || addressType === AddressType.P2C) {
72
77
  // [type, ...hash]