allow wallet transactions to lookup their real counterparts.

This commit is contained in:
Christopher Jeffrey 2014-11-13 16:46:05 -08:00
parent a9a5f7c4ad
commit 7aaf4dce94
2 changed files with 29 additions and 9 deletions

View File

@ -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;
};

View File

@ -4455,7 +4455,8 @@ NAN_METHOD(WalletGetTransaction) {
Local<Array> details = NanNew<Array>();
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<String>("details"), details);
//std::string strHex = EncodeHexTx(static_cast<CTransaction>(wtx));