diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 9f1b1939..e7f1196d 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -417,22 +417,23 @@ Bitcoin.prototype.getMiningInfo = function() { return bitcoindjs.getMiningInfo(); }; -Bitcoin.prototype.getAddrTransactions = function(addr, callback) { +Bitcoin.prototype.getAddrTransactions = function(address, callback) { if (!bitcoin.db) { var tiny = require('tiny').json; + tiny.debug = function() {}; bitcoin.db = tiny({ file: process.env.HOME + '/.bitcoindjs.addr.db', saveIndex: false, initialCache: false }); } - return bitcoin.db.get(addr, function(err, records) { + return bitcoin.db.get(address, function(err, records) { var found = !err && records && records.length; var last = found && records[records.length - 1]; var limit = 15 * 60 * 1000; if (!found || last.timestamp + limit < Date.now()) { var options = { - address: addr, + address: address, blockindex: (records || []).reduce(function(out, record) { return record.blockindex > out ? record.blockindex @@ -443,7 +444,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) { if (err) return callback(err); addr = bitcoin.addr(addr); if (addr.tx[0] && !addr.tx[0].vout[0]) { - return bitcoin.db.set(addr, [{ + return bitcoin.db.set(address, [{ txid: null, blockhash: null, blockindex: null, @@ -467,7 +468,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) { timestamp: Date.now() }); }); - return bitcoin.db.set(addr, set, function() { + return bitcoin.db.set(address, set, function() { return callback(null, addr); }); }); @@ -485,7 +486,7 @@ Bitcoin.prototype.getAddrTransactions = function(addr, callback) { }); }, function() { return callback(null, bitcoin.addr({ - address: addr, + address: address, tx: txs })); });