diff --git a/lib/bitcoind.js b/lib/bitcoind.js index d7b446ba..84a64e6e 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -809,13 +809,25 @@ Wallet.prototype.getUnconfirmedBalance = function(options) { }; // XXX Wallet Transactions -// Convert to regular TX Wallet.prototype.listTransactions = -Wallet.prototype.getTransactions = function(options) { +Wallet.prototype.getTransactions = function(options, callback) { var txs = bitcoindjs.walletListTransactions(options || {}); - // return txs.map(function(tx) { - // return Transaction.fromHex(tx.hex); - // }); + if (callback) { + // Retrieve to regular TXs from disk: + var out = []; + return utils.forEach(txs, function(tx, next) { + return bitcoindjs.getTx(tx.txid, tx.blockhash, function(err, tx_) { + if (err) return next(err); + var tx = bitcoin.tx(tx_); + tx._walletTransaction = tx_; + out.push(tx); + return next(); + }); + }, function(err) { + if (err) return callback(err); + return callback(null, out); + }); + } return txs; }; @@ -830,10 +842,17 @@ Wallet.prototype.getAccounts = function(options) { }; // XXX Wallet Transaction -// Convert to regular TX -Wallet.prototype.getTransaction = function(options) { +Wallet.prototype.getTransaction = function(options, callback) { var tx = bitcoindjs.walletGetTransaction(options || {}); - // return tx ? Transaction.fromHex(tx.hex) : tx; + if (callback) { + // Retrieve to regular TX from disk: + return bitcoindjs.getTx(tx.txid, tx.blockhash, function(err, tx_) { + if (err) return next(err); + var tx = bitcoin.tx(tx_); + tx._walletTransaction = tx_; + return callback(null, tx); + }); + } return tx; }; diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index b72812f0..c3021ffd 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -4455,7 +4455,8 @@ NAN_METHOD(WalletGetTransaction) { Local details = NanNew(); int a_count = 0; - ListTransactions_V8(wtx, "*", 0, false, details, filter, &a_count); + // NOTE: fLong is set to false in rpcwallet.cpp + ListTransactions_V8(wtx, "*", 0, /*fLong=*/ true, details, filter, &a_count); entry->Set(NanNew("details"), details); //std::string strHex = EncodeHexTx(static_cast(wtx));