improve script type tests. improve input/output data.
This commit is contained in:
parent
b16a86b2d4
commit
1c8604477f
@ -52,6 +52,7 @@ function Block(data, subtype) {
|
|||||||
tx = bcoin.tx(tx);
|
tx = bcoin.tx(tx);
|
||||||
tx.block = self.hash('hex');
|
tx.block = self.hash('hex');
|
||||||
tx.ts = tx.ts || self.ts;
|
tx.ts = tx.ts || self.ts;
|
||||||
|
// self.tx.push(tx.hash('hex'));
|
||||||
return tx;
|
return tx;
|
||||||
});
|
});
|
||||||
this.invalid = !this._checkBlock();
|
this.invalid = !this._checkBlock();
|
||||||
|
|||||||
@ -51,7 +51,17 @@ function Input(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Input.prototype.__defineGetter__('data', function() {
|
Input.prototype.__defineGetter__('data', function() {
|
||||||
return Input.getData(this);
|
var data;
|
||||||
|
|
||||||
|
if (this._data)
|
||||||
|
return this._data;
|
||||||
|
|
||||||
|
data = Input.getData(this);
|
||||||
|
|
||||||
|
if (this.script.length && this.out.tx)
|
||||||
|
utils.hidden(this, '_data', data);
|
||||||
|
|
||||||
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
Input.prototype.__defineGetter__('addr', function() {
|
Input.prototype.__defineGetter__('addr', function() {
|
||||||
|
|||||||
@ -35,7 +35,17 @@ function Output(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Output.prototype.__defineGetter__('data', function() {
|
Output.prototype.__defineGetter__('data', function() {
|
||||||
return Output.getData(this);
|
var data;
|
||||||
|
|
||||||
|
if (this._data)
|
||||||
|
return this._data;
|
||||||
|
|
||||||
|
data = Output.getData(this);
|
||||||
|
|
||||||
|
if (this.script.length && this.value.cmpn(0) !== 0)
|
||||||
|
utils.hidden(this, '_data', data);
|
||||||
|
|
||||||
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
Output.prototype.__defineGetter__('addr', function() {
|
Output.prototype.__defineGetter__('addr', function() {
|
||||||
|
|||||||
@ -897,6 +897,8 @@ script.spendable = function spendable(s, lockTime) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isPubkey = function isPubkey(s, key) {
|
script.isPubkey = function isPubkey(s, key) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (script.lockTime(s))
|
if (script.lockTime(s))
|
||||||
s = s.slice(3);
|
s = s.slice(3);
|
||||||
|
|
||||||
@ -914,6 +916,8 @@ script.isPubkey = function isPubkey(s, key) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (script.lockTime(s))
|
if (script.lockTime(s))
|
||||||
s = s.slice(3);
|
s = s.slice(3);
|
||||||
|
|
||||||
@ -938,6 +942,8 @@ script.isPubkeyhash = function isPubkeyhash(s, hash) {
|
|||||||
script.isMultisig = function isMultisig(s, pubs) {
|
script.isMultisig = function isMultisig(s, pubs) {
|
||||||
var m, n, keys, isArray, total;
|
var m, n, keys, isArray, total;
|
||||||
|
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (script.lockTime(s))
|
if (script.lockTime(s))
|
||||||
s = s.slice(3);
|
s = s.slice(3);
|
||||||
|
|
||||||
@ -990,6 +996,8 @@ script.isMultisig = function isMultisig(s, pubs) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isScripthash = function isScripthash(s, hash) {
|
script.isScripthash = function isScripthash(s, hash) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (script.lockTime(s))
|
if (script.lockTime(s))
|
||||||
s = s.slice(3);
|
s = s.slice(3);
|
||||||
|
|
||||||
@ -1011,6 +1019,8 @@ script.isScripthash = function isScripthash(s, hash) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isColored = function isColored(s) {
|
script.isColored = function isColored(s) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (s.length !== 2)
|
if (s.length !== 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1035,6 +1045,8 @@ script.standardInput = function standardInput(s) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isPubkeyInput = function isPubkeyInput(s, key, tx, i) {
|
script.isPubkeyInput = function isPubkeyInput(s, key, tx, i) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (s.length !== 1 || !Array.isArray(s[0]))
|
if (s.length !== 1 || !Array.isArray(s[0]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1050,6 +1062,8 @@ script.isPubkeyInput = function isPubkeyInput(s, key, tx, i) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
script.isPubkeyhashInput = function isPubkeyhashInput(s, key) {
|
script.isPubkeyhashInput = function isPubkeyhashInput(s, key) {
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (s.length !== 2 || !Array.isArray(s[0]) || !Array.isArray(s[1]))
|
if (s.length !== 2 || !Array.isArray(s[0]) || !Array.isArray(s[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1071,6 +1085,8 @@ script.isPubkeyhashInput = function isPubkeyhashInput(s, key) {
|
|||||||
script.isMultisigInput = function isMultisigInput(s, pubs, tx, i) {
|
script.isMultisigInput = function isMultisigInput(s, pubs, tx, i) {
|
||||||
var i, res, o;
|
var i, res, o;
|
||||||
|
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (s.length < 3)
|
if (s.length < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1095,6 +1111,8 @@ script.isMultisigInput = function isMultisigInput(s, pubs, tx, i) {
|
|||||||
script.isScripthashInput = function isScripthashInput(s, redeem) {
|
script.isScripthashInput = function isScripthashInput(s, redeem) {
|
||||||
var i, res, r, keys;
|
var i, res, r, keys;
|
||||||
|
|
||||||
|
s = script.subscript(s);
|
||||||
|
|
||||||
if (s.length < 4)
|
if (s.length < 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ function TX(data, block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!data.ts && block && block.hasTX(this.hash('hex'))) {
|
if (!data.ts && block && block.hasTX(this.hash('hex'))) {
|
||||||
// if (!data.block && block) {
|
// if (block) {
|
||||||
this.ts = block.ts;
|
this.ts = block.ts;
|
||||||
this.block = block.hash('hex');
|
this.block = block.hash('hex');
|
||||||
}
|
}
|
||||||
@ -369,8 +369,7 @@ TX.prototype.scriptOutput = function scriptOutput(output, options) {
|
|||||||
options = options || output;
|
options = options || output;
|
||||||
|
|
||||||
var script = output.script;
|
var script = output.script;
|
||||||
var keys, m, n;
|
var keys, m, n, hash, color;
|
||||||
var hash, color;
|
|
||||||
|
|
||||||
if (Array.isArray(options.keys || options.address)) {
|
if (Array.isArray(options.keys || options.address)) {
|
||||||
// Raw multisig transaction
|
// Raw multisig transaction
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user