From 607b3b79833f8b62bf1d80aadae6692a50abf511 Mon Sep 17 00:00:00 2001
From: Daniel Cousens <github@dcousens.com>
Date: Mon, 16 Mar 2015 10:51:21 +1100
Subject: [PATCH] networks: use byteLength over toBuffer

---
 src/networks.js  | 2 +-
 test/networks.js | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/networks.js b/src/networks.js
index 264ce8f..d4ba24e 100644
--- a/src/networks.js
+++ b/src/networks.js
@@ -123,7 +123,7 @@ var networks = {
 
 function estimateFee (tx, network) {
   var baseFee = network.feePerKb
-  var byteSize = tx.toBuffer().length
+  var byteSize = tx.byteLength()
 
   var fee = baseFee * Math.ceil(byteSize / 1000)
   if (network.dustSoftThreshold === undefined) return fee
diff --git a/test/networks.js b/test/networks.js
index 79c9288..ead69d8 100644
--- a/test/networks.js
+++ b/test/networks.js
@@ -10,13 +10,13 @@ var Transaction = require('../src/transaction')
 var fixtures = require('./fixtures/network')
 
 describe('networks', function () {
-  var txToBuffer
+  var txByteLength
   before(function () {
-    txToBuffer = sinon.stub(Transaction.prototype, 'toBuffer')
+    txByteLength = sinon.stub(Transaction.prototype, 'byteLength')
   })
 
   after(function () {
-    Transaction.prototype.toBuffer.restore()
+    Transaction.prototype.byteLength.restore()
   })
 
   describe('constants', function () {
@@ -39,8 +39,7 @@ describe('networks', function () {
         var network = networks[f.network]
 
         it('calculates the fee correctly for ' + f.description, function () {
-          var buffer = new Buffer(f.txSize)
-          txToBuffer.returns(buffer)
+          txByteLength.returns(f.txSize)
 
           var estimateFee = network.estimateFee
           var tx = new Transaction()