From 24b92a2b584acccc322af0ee42ebacd5b0fc16c4 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 1 Oct 2016 21:45:42 -0700 Subject: [PATCH] bip70: refactor deps. --- lib/bip70/bip70.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/bip70/bip70.js b/lib/bip70/bip70.js index 3138b09d..bc280cdf 100644 --- a/lib/bip70/bip70.js +++ b/lib/bip70/bip70.js @@ -6,10 +6,12 @@ 'use strict'; -var bcoin = require('../env'); var assert = require('assert'); -var utils = bcoin.utils; +var utils = require('../utils/utils'); var crypto = require('../crypto/crypto'); +var Output = require('../primitives/output'); +var TX = require('../primitives/tx'); +var Script = require('../script/script'); var x509 = require('./x509'); var asn1 = require('./asn1'); var protobuf = require('./protobuf'); @@ -276,7 +278,7 @@ PaymentDetails.prototype.fromOptions = function fromOptions(options) { if (options.outputs) { assert(Array.isArray(options.outputs)); for (i = 0; i < options.outputs.length; i++) { - output = new bcoin.output(options.outputs[i]); + output = new Output(options.outputs[i]); this.outputs.push(output); } } @@ -362,7 +364,7 @@ PaymentDetails.prototype.fromRaw = function fromRaw(data) { while (p.nextTag() === 2) { op = new ProtoReader(p.readFieldBytes(2)); - output = new bcoin.output(); + output = new Output(); output.value = op.readFieldU64(1, true); output.script.fromRaw(op.readFieldBytes(2, true)); this.outputs.push(output); @@ -440,7 +442,7 @@ Payment.prototype.fromOptions = function fromOptions(options) { if (options.transactions) { assert(Array.isArray(options.transactions)); for (i = 0; i < options.transactions.length; i++) { - tx = new bcoin.tx(options.transactions[i]); + tx = new TX(options.transactions[i]); this.transactions.push(tx); } } @@ -448,7 +450,7 @@ Payment.prototype.fromOptions = function fromOptions(options) { if (options.refundTo) { assert(Array.isArray(options.refundTo)); for (i = 0; i < options.refundTo.length; i++) { - output = new bcoin.output(options.refundTo[i]); + output = new Output(options.refundTo[i]); this.refundTo.push(output); } } @@ -475,15 +477,15 @@ Payment.prototype.fromRaw = function fromRaw(data) { this.merchantData = p.readFieldBytes(1, true); while (p.nextTag() === 2) { - tx = bcoin.tx.fromRaw(p.readFieldBytes(2)); + tx = TX.fromRaw(p.readFieldBytes(2)); this.transactions.push(tx); } while (p.nextTag() === 3) { op = new ProtoReader(p.readFieldBytes(3)); - output = new bcoin.output(); + output = new Output(); output.value = op.readFieldU64(1, true); - output.script = bcoin.script.fromRaw(op.readFieldBytes(2, true)); + output.script = Script.fromRaw(op.readFieldBytes(2, true)); this.refundTo.push(output); }