Simplify Script constructor. close #41
This commit is contained in:
parent
354d31a297
commit
4a4e75d007
1 changed files with 5 additions and 12 deletions
|
@ -4,21 +4,14 @@ var conv = require('./convert');
|
|||
var Address = require('./address');
|
||||
|
||||
var Script = function(data) {
|
||||
if (!data) {
|
||||
this.buffer = [];
|
||||
} else if ('string' == typeof data) {
|
||||
this.buffer = conv.hexToBytes(data);
|
||||
} else if (util.isArray(data)) {
|
||||
this.buffer = data;
|
||||
} else if (data instanceof Script) {
|
||||
this.buffer = data.buffer;
|
||||
} else {
|
||||
throw new Error('Invalid script');
|
||||
}
|
||||
|
||||
this.buffer = data || [];
|
||||
this.parse();
|
||||
};
|
||||
|
||||
Script.fromHex = function(data) {
|
||||
return new Script(conv.hexToBytes(data))
|
||||
};
|
||||
|
||||
Script.fromPubKey = function(str) {
|
||||
var script = new Script();
|
||||
var s = str.split(' ');
|
||||
|
|
Loading…
Reference in a new issue