diff --git a/src/script.js b/src/script.js index 7a544bd..5d04371 100644 --- a/src/script.js +++ b/src/script.js @@ -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(' ');