MCPcopy Index your code
hub / github.com/bcoin-org/bcoin / isMultisig

Method isMultisig

lib/script/script.js:1925–1957  ·  view source on GitHub ↗

* Test whether the output script is pay-to-multisig. * @param {Boolean} [minimal=false] - Minimaldata only. * @returns {Boolean}

(minimal)

Source from the content-addressed store, hash-verified

1923 */
1924
1925 isMultisig(minimal) {
1926 if (this.code.length < 4 || this.code.length > 19)
1927 return false;
1928
1929 if (this.getOp(-1) !== opcodes.OP_CHECKMULTISIG)
1930 return false;
1931
1932 const m = this.getSmall(0);
1933
1934 if (m < 1)
1935 return false;
1936
1937 const n = this.getSmall(-2);
1938
1939 if (n < 1 || m > n)
1940 return false;
1941
1942 if (this.code.length !== n + 3)
1943 return false;
1944
1945 for (let i = 1; i < n + 1; i++) {
1946 const op = this.code[i];
1947 const size = op.toLength();
1948
1949 if (size !== 33 && size !== 65)
1950 return false;
1951
1952 if (minimal && !op.isMinimal())
1953 return false;
1954 }
1955
1956 return true;
1957 }
1958
1959 /**
1960 * Get multisig m and n values if present.

Callers 6

getTypeMethod · 0.95
getMultisigMethod · 0.95
fromMultisigScriptMethod · 0.80
checkStandardMethod · 0.80
isWatchedMethod · 0.80
fromScriptMethod · 0.80

Calls 4

getOpMethod · 0.95
getSmallMethod · 0.95
toLengthMethod · 0.80
isMinimalMethod · 0.45

Tested by

no test coverage detected