Add blockhash and blockindex to transaction info
authorLuke Dashjr <luke-jr+git@utopios.org>
Fri, 27 May 2011 04:05:16 +0000 (00:05 -0400)
committerLuke Dashjr <luke-jr+git@utopios.org>
Sat, 17 Dec 2011 00:05:41 +0000 (19:05 -0500)
src/rpc.cpp

index 885ffd1..accaf19 100644 (file)
@@ -90,7 +90,13 @@ Value ValueFromAmount(int64 amount)
 
 void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
 {
-    entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));
+    int confirms = wtx.GetDepthInMainChain();
+    entry.push_back(Pair("confirmations", confirms));
+    if (confirms)
+    {
+        entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex()));
+        entry.push_back(Pair("blockindex", wtx.nIndex));
+    }
     entry.push_back(Pair("txid", wtx.GetHash().GetHex()));
     entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));
     BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)