Browse Source

Simplify Script constructor. close #41

hk-custom-address
Andreas Brekken 11 years ago
parent
commit
4a4e75d007
  1. 17
      src/script.js

17
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(' ');

Loading…
Cancel
Save