wallet: improve ownInput and ownOutput.
This commit is contained in:
parent
dbd3b5025a
commit
9442920e73
@ -236,6 +236,20 @@ script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
|||||||
return s[2];
|
return s[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
script.isSimplePubkeyhash = function isSimplePubkeyhash(s, hash) {
|
||||||
|
if (s.length !== 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var match = Array.isArray(s[0]) && s[1] === 'checksig';
|
||||||
|
if (!match)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (hash)
|
||||||
|
return utils.isEqual(s[0], hash);
|
||||||
|
else
|
||||||
|
return s[0];
|
||||||
|
};
|
||||||
|
|
||||||
script.isMultisig = function isMultisig(s, key) {
|
script.isMultisig = function isMultisig(s, key) {
|
||||||
if (s.length < 4)
|
if (s.length < 4)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -170,6 +170,9 @@ Wallet.prototype.ownOutput = function ownOutput(tx, index) {
|
|||||||
if (bcoin.script.isPubkeyhash(s, hash))
|
if (bcoin.script.isPubkeyhash(s, hash))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (bcoin.script.isSimplePubkeyhash(s, hash))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (bcoin.script.isMultisig(s, key))
|
if (bcoin.script.isMultisig(s, key))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -189,6 +192,11 @@ Wallet.prototype.ownInput = function ownInput(tx, index) {
|
|||||||
if (index !== undefined && index !== i)
|
if (index !== undefined && index !== i)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (bcoin.script.isPubkeyhashInput(input.script)
|
||||||
|
&& utils.isEqual(input.script[1], key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!input.out.tx)
|
if (!input.out.tx)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user