check for nulldata in script extraction.
This commit is contained in:
parent
5e00e42903
commit
8abaef49a9
@ -68,7 +68,7 @@ Input.prototype.__defineGetter__('hash', function() {
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('address', function() {
|
||||
return this.data.scriptaddress || this.addresses[0] || this._id;
|
||||
return this.data.scriptaddress || this.addresses[0] || this.getID();
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('signatures', function() {
|
||||
@ -109,6 +109,10 @@ Input.prototype.__defineGetter__('lock', function() {
|
||||
return this.output.lock;
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('flags', function() {
|
||||
return this.data.flags;
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('text', function() {
|
||||
return this.data.text;
|
||||
});
|
||||
@ -129,17 +133,6 @@ Input.prototype.__defineGetter__('tx', function() {
|
||||
return this.out.tx;
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('_id', function() {
|
||||
var data = [].concat(
|
||||
this.out.hash,
|
||||
this.out.index,
|
||||
bcoin.script.encode(this.script),
|
||||
this.seq
|
||||
);
|
||||
var hash = utils.toHex(utils.dsha256(data));
|
||||
return '[' + this.type + ':' + hash.slice(0, 7) + ']';
|
||||
});
|
||||
|
||||
Input.prototype.__defineGetter__('addr', function() {
|
||||
return this.address;
|
||||
});
|
||||
@ -232,6 +225,12 @@ Input.getData = function getData(input) {
|
||||
return utils.merge(def, bcoin.script.getInputData(input.script));
|
||||
};
|
||||
|
||||
Input.prototype.getID = function getID() {
|
||||
var data = bcoin.script.encode(this.script);
|
||||
var hash = utils.toHex(utils.ripesha(data));
|
||||
return '[' + this.type + ':' + hash.slice(0, 7) + ']';
|
||||
};
|
||||
|
||||
Input.prototype.inspect = function inspect() {
|
||||
var output = this.output
|
||||
? this.output.inspect()
|
||||
@ -245,9 +244,11 @@ Input.prototype.inspect = function inspect() {
|
||||
type: this.type,
|
||||
subtype: this.subtype,
|
||||
address: this.address,
|
||||
addresses: this.addresses,
|
||||
signatures: this.signatures.map(utils.toHex),
|
||||
keys: this.keys.map(utils.toHex),
|
||||
hashes: this.hashes.map(utils.toHex),
|
||||
addresses: this.addresses,
|
||||
scriptaddress: this.scriptaddress,
|
||||
signatures: this.signatures.map(utils.toHex),
|
||||
text: this.text,
|
||||
lock: this.lock,
|
||||
value: utils.btc(output.value),
|
||||
|
||||
@ -70,7 +70,7 @@ Output.prototype.__defineGetter__('hash', function() {
|
||||
});
|
||||
|
||||
Output.prototype.__defineGetter__('address', function() {
|
||||
return this.data.scriptaddress || this.addresses[0] || this._id;
|
||||
return this.data.scriptaddress || this.addresses[0] || this.getID();
|
||||
});
|
||||
|
||||
Output.prototype.__defineGetter__('signatures', function() {
|
||||
@ -105,17 +105,12 @@ Output.prototype.__defineGetter__('lock', function() {
|
||||
return bcoin.script.lockTime(this.script);
|
||||
});
|
||||
|
||||
Output.prototype.__defineGetter__('text', function() {
|
||||
return this.data.text;
|
||||
Output.prototype.__defineGetter__('flags', function() {
|
||||
return this.data.flags;
|
||||
});
|
||||
|
||||
Output.prototype.__defineGetter__('_id', function() {
|
||||
var data = [].concat(
|
||||
this.value.toArray(),
|
||||
bcoin.script.encode(this.script)
|
||||
);
|
||||
var hash = utils.toHex(utils.dsha256(data));
|
||||
return '[' + this.type + ':' + hash.slice(0, 7) + ']';
|
||||
Output.prototype.__defineGetter__('text', function() {
|
||||
return this.data.text;
|
||||
});
|
||||
|
||||
Output.prototype.__defineGetter__('addr', function() {
|
||||
@ -187,6 +182,12 @@ Output.getData = function getData(output) {
|
||||
return utils.merge(def, bcoin.script.getOutputData(output.script));
|
||||
};
|
||||
|
||||
Output.prototype.getID = function getID() {
|
||||
var data = bcoin.script.encode(this.script);
|
||||
var hash = utils.toHex(utils.ripesha(data));
|
||||
return '[' + this.type + ':' + hash.slice(0, 7) + ']';
|
||||
};
|
||||
|
||||
Output.prototype.inspect = function inspect() {
|
||||
return {
|
||||
type: this.type,
|
||||
@ -194,6 +195,7 @@ Output.prototype.inspect = function inspect() {
|
||||
keys: this.keys.map(utils.toHex),
|
||||
hashes: this.hashes.map(utils.toHex),
|
||||
addresses: this.addresses,
|
||||
scriptaddress: this.scriptaddress,
|
||||
m: this.m,
|
||||
n: this.n,
|
||||
text: this.text,
|
||||
|
||||
@ -1416,6 +1416,15 @@ script.getOutputData = function getOutputData(s) {
|
||||
};
|
||||
}
|
||||
|
||||
if (script.isNulldata(s)) {
|
||||
return {
|
||||
type: 'nulldata',
|
||||
side: 'output',
|
||||
nulldata: s[1],
|
||||
text: utils.array2utf8(s[1])
|
||||
};
|
||||
}
|
||||
|
||||
return script.getUnknownData(s);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user