minor refactor.
This commit is contained in:
parent
dddd6b0b49
commit
2299ee757e
@ -917,6 +917,8 @@ script.spendable = function spendable(s, lockTime) {
|
||||
};
|
||||
|
||||
script.isPubkey = function isPubkey(s, key) {
|
||||
var res;
|
||||
|
||||
s = script.subscript(s);
|
||||
|
||||
if (script.lockTime(s))
|
||||
@ -925,8 +927,9 @@ script.isPubkey = function isPubkey(s, key) {
|
||||
if (s.length !== 2)
|
||||
return false;
|
||||
|
||||
var match = Array.isArray(s[0]) && s[1] === 'checksig';
|
||||
if (!match)
|
||||
res = Array.isArray(s[0]) && s[1] === 'checksig';
|
||||
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
if (key)
|
||||
@ -936,6 +939,8 @@ script.isPubkey = function isPubkey(s, key) {
|
||||
};
|
||||
|
||||
script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
||||
var res;
|
||||
|
||||
s = script.subscript(s);
|
||||
|
||||
if (script.lockTime(s))
|
||||
@ -944,13 +949,13 @@ script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
||||
if (s.length !== 5)
|
||||
return false;
|
||||
|
||||
var match = s[0] === 'dup'
|
||||
res = s[0] === 'dup'
|
||||
&& s[1] === 'hash160'
|
||||
&& Array.isArray(s[2])
|
||||
&& s[3] === 'eqverify'
|
||||
&& s[4] === 'checksig';
|
||||
|
||||
if (!match)
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
if (hash)
|
||||
@ -1065,13 +1070,15 @@ script.standardInput = function standardInput(s) {
|
||||
};
|
||||
|
||||
script.isPubkeyInput = function isPubkeyInput(s, key, tx, i) {
|
||||
var res;
|
||||
|
||||
s = script.subscript(s);
|
||||
|
||||
if (s.length !== 1 || !Array.isArray(s[0]))
|
||||
return false;
|
||||
|
||||
// var res = script.isValidSig(s[0]);
|
||||
var res = 9 <= s[0].length && s[0].length <= 73;
|
||||
// res = script.isValidSig(s[0]);
|
||||
res = 9 <= s[0].length && s[0].length <= 73;
|
||||
if (!res)
|
||||
return false;
|
||||
|
||||
@ -1082,15 +1089,17 @@ script.isPubkeyInput = function isPubkeyInput(s, key, tx, i) {
|
||||
};
|
||||
|
||||
script.isPubkeyhashInput = function isPubkeyhashInput(s, key) {
|
||||
var res;
|
||||
|
||||
s = script.subscript(s);
|
||||
|
||||
if (s.length !== 2 || !Array.isArray(s[0]) || !Array.isArray(s[1]))
|
||||
return false;
|
||||
|
||||
// var res = script.isValidSig(s[0])
|
||||
// res = script.isValidSig(s[0])
|
||||
// && 33 <= s[1].length && s[1].length <= 65;
|
||||
|
||||
var res = 9 <= s[0].length && s[0].length <= 73
|
||||
res = 9 <= s[0].length && s[0].length <= 73
|
||||
&& 33 <= s[1].length && s[1].length <= 65;
|
||||
|
||||
if (!res)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user