diff --git a/lib/bitcoind.js b/lib/bitcoind.js index eaf50387..d46518b7 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -415,10 +415,10 @@ Bitcoin.prototype.getMiningInfo = function() { }; Bitcoin.prototype.getAddrTransactions = function(addr, callback) { - return bitcoindjs.getAddrTransactions(addr, function(err, result) { + return bitcoindjs.getAddrTransactions(addr, function(err, addr) { if (err) return callback(err); - result._addrFlag = true; - return callback(null, result); + addr = bitcoin.addr(addr); + return callback(null, addr); }); }; @@ -710,6 +710,41 @@ Transaction.prototype.broadcast = function(options, callback) { return Transaction.broadcast(this, options, callback); }; +/** + * Addresses + */ + +function Addresses(data) { + if (!(this instanceof Addresses)) { + return new Addresses(data); + } + + if (data instanceof Addresses) { + return data; + } + + var self = this; + + Object.keys(data).forEach(function(key) { + if (!self[key]) { + self[key] = data[key]; + } + }); +} + +Object.defineProperty(Transaction.prototype, '_addrFlag', { + __proto__: null, + configurable: false, + enumerable: false, + writable: false, + value: {} +}); + +Addresses.isAddresses = +Addresses.isAddr = function(addr) { + return addr._txFlag === Addresses.prototype._addrFlag; +}; + /** * Wallet * Singleton @@ -954,6 +989,10 @@ exports.Transaction = Transaction; exports.transaction = Transaction; exports.tx = Transaction; +exports.Addresses = Addresses; +exports.addresses = Addresses; +exports.addr = Addresses; + exports.Wallet = Wallet; exports.wallet = Wallet;