use utils.indexOf.
This commit is contained in:
parent
7829ff3bea
commit
15c63eb14a
@ -270,12 +270,7 @@ MTX.prototype.scriptInput = function scriptInput(index, addr) {
|
|||||||
vector[1] = addr.publicKey;
|
vector[1] = addr.publicKey;
|
||||||
} else if (bcoin.script.isMultisig(prev)) {
|
} else if (bcoin.script.isMultisig(prev)) {
|
||||||
// Multisig
|
// Multisig
|
||||||
for (i = 0; i < prev.length; i++) {
|
if (utils.indexOf(prev, addr.publicKey) === -1)
|
||||||
if (utils.isEqual(prev[i], addr.publicKey))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i === prev.length)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Already has a script template (at least)
|
// Already has a script template (at least)
|
||||||
@ -294,12 +289,7 @@ MTX.prototype.scriptInput = function scriptInput(index, addr) {
|
|||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
vector[i + 1] = dummy;
|
vector[i + 1] = dummy;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < prev.length; i++) {
|
if (utils.indexOf(prev, addr.publicKey) === -1)
|
||||||
if (utils.isEqual(prev[i], addr.publicKey))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i === prev.length)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Already has a script template (at least)
|
// Already has a script template (at least)
|
||||||
@ -499,15 +489,12 @@ MTX.prototype.signInput = function signInput(index, addr, type) {
|
|||||||
|
|
||||||
// Find the key index so we can place
|
// Find the key index so we can place
|
||||||
// the signature in the same index.
|
// the signature in the same index.
|
||||||
for (ki = 0; ki < keys.length; ki++) {
|
ki = utils.indexOf(keys, addr.publicKey);
|
||||||
if (utils.isEqual(addr.publicKey, keys[ki]))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Our public key is not in the prev_out
|
// Our public key is not in the prev_out
|
||||||
// script. We tried to sign a transaction
|
// script. We tried to sign a transaction
|
||||||
// that is not redeemable by us.
|
// that is not redeemable by us.
|
||||||
if (ki === keys.length)
|
if (ki === -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Offset key index by one to turn it into
|
// Offset key index by one to turn it into
|
||||||
|
|||||||
@ -1671,10 +1671,12 @@ utils.checkMerkleBranch = function checkMerkleBranch(hash, branch, index) {
|
|||||||
utils.indexOf = function indexOf(arr, buf) {
|
utils.indexOf = function indexOf(arr, buf) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
assert(Array.isArray(arr));
|
utils.assert(Array.isArray(arr));
|
||||||
assert(Buffer.isBuffer(buf));
|
utils.assert(Buffer.isBuffer(buf));
|
||||||
|
|
||||||
for (i = 0; i < arr.length; i++) {
|
for (i = 0; i < arr.length; i++) {
|
||||||
|
if (!Buffer.isBuffer(arr[i]))
|
||||||
|
continue;
|
||||||
if (utils.isEqual(arr[i], buf))
|
if (utils.isEqual(arr[i], buf))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user