improve script.isValidSig.
This commit is contained in:
parent
2e7892c798
commit
0aff6d7cfe
@ -1073,7 +1073,7 @@ script.isMultisigInput = function isMultisigInput(s, pubs, tx, i) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 1; i < s.length; i++) {
|
for (i = 1; i < s.length; i++) {
|
||||||
// res = Array.isArray(s[i]) && script.isValidSig(s[i]);
|
// res = script.isValidSig(s[i]);
|
||||||
res = Array.isArray(s[i]) && 9 <= s[i].length && s[i].length <= 73;
|
res = Array.isArray(s[i]) && 9 <= s[i].length && s[i].length <= 73;
|
||||||
if (!res)
|
if (!res)
|
||||||
return false;
|
return false;
|
||||||
@ -1097,7 +1097,7 @@ script.isScripthashInput = function isScripthashInput(s, redeem) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 1; i < s.length - 1; i++) {
|
for (i = 1; i < s.length - 1; i++) {
|
||||||
// res = Array.isArray(s[i]) && script.isValidSig(s[i]);
|
// res = script.isValidSig(s[i]);
|
||||||
res = Array.isArray(s[i]) && 9 <= s[i].length && s[i].length <= 73;
|
res = Array.isArray(s[i]) && 9 <= s[i].length && s[i].length <= 73;
|
||||||
if (!res)
|
if (!res)
|
||||||
return false;
|
return false;
|
||||||
@ -1126,7 +1126,7 @@ script.isScripthashInput = function isScripthashInput(s, redeem) {
|
|||||||
*
|
*
|
||||||
* This function is consensus-critical since BIP66.
|
* This function is consensus-critical since BIP66.
|
||||||
*/
|
*/
|
||||||
script.isValidSig = function(sig) {
|
script.isValidSig = function(sig, allowZero) {
|
||||||
var lenR, lenS;
|
var lenR, lenS;
|
||||||
|
|
||||||
if (!Array.isArray(sig))
|
if (!Array.isArray(sig))
|
||||||
@ -1134,7 +1134,7 @@ script.isValidSig = function(sig) {
|
|||||||
|
|
||||||
// Empty signature. Not strictly DER encoded, but allowed to provide a
|
// Empty signature. Not strictly DER encoded, but allowed to provide a
|
||||||
// compact way to provide an invalid signature for use with CHECK(MULTI)SIG
|
// compact way to provide an invalid signature for use with CHECK(MULTI)SIG
|
||||||
if (sig.length === 0)
|
if (allowZero && sig.length === 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash]
|
// Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user