diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index 537b2df0..faa0228e 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -4070,7 +4070,10 @@ Script.parseRaw = function parseRaw(data, enc) { if (enc === 'hex') data = new Buffer(data, 'hex'); - return Script.parseScript(data); + return { + code: Script.decode(data), + raw: data + }; }; /** diff --git a/test/script-test.js b/test/script-test.js index b0cd3db0..4ac330cc 100644 --- a/test/script-test.js +++ b/test/script-test.js @@ -39,15 +39,13 @@ describe('Script', function() { it('should recognize a P2SH output', function () { var hex = 'a91419a7d869032368fd1f1e26e5e73a4ad0e474960e87' - var encoded = new Buffer(hex, 'hex') - var decoded = new bcoin.script(encoded); + var decoded = bcoin.script.fromRaw(hex, 'hex'); assert(decoded.isScripthash()) }); it('should recognize a Null Data output', function () { var hex = '6a28590c080112220a1b353930632e6f7267282a5f5e294f7665726c6179404f7261636c65103b1a010c' - var encoded = new Buffer(hex, 'hex') - var decoded = new Script(encoded); + var decoded = bcoin.script.fromRaw(hex, 'hex'); assert(decoded.isNulldata()) }); diff --git a/test/tx-test.js b/test/tx-test.js index ea1fdc9d..330f1611 100644 --- a/test/tx-test.js +++ b/test/tx-test.js @@ -96,14 +96,14 @@ describe('TX', function() { var suffix = nocache ? ' without cache' : ' with cache'; it('should decode/encode with parser/framer' + suffix, function() { - var tx = bcoin.tx(parser.parseTX(new Buffer(raw, 'hex'))); + var tx = bcoin.tx.fromRaw(raw, 'hex'); clearCache(tx, nocache); assert.equal(tx.render().toString('hex'), raw); }); it('should be verifiable' + suffix, function() { - var tx = bcoin.tx(parser.parseTX(new Buffer(raw, 'hex'))); - var p = bcoin.tx(parser.parseTX(new Buffer(inp, 'hex'))); + var tx = bcoin.tx.fromRaw(raw, 'hex'); + var p = bcoin.tx.fromRaw(inp, 'hex'); tx.fillCoins(p); clearCache(tx, nocache); @@ -240,7 +240,7 @@ describe('TX', function() { return; var tx = bcoin.tx.fromRaw(data[0], 'hex'); clearCache(tx, nocache); - var script = new bcoin.script(new Buffer(data[1], 'hex')); + var script = bcoin.script.fromRaw(data[1], 'hex'); clearCache(script, nocache); var index = data[2]; var type = data[3];