Add getworkex
[novacoin.git] / src / bitcoinrpc.cpp
index 4239f3f..3020691 100644 (file)
@@ -211,17 +211,21 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
     {
         if (fPrintTransactionDetail)
         {
-            txinfo.push_back(tx.ToStringShort());
-            txinfo.push_back(DateTimeStrFormat(tx.nTime));
-            BOOST_FOREACH(const CTxIn& txin, tx.vin)
-                txinfo.push_back(txin.ToStringShort());
-            BOOST_FOREACH(const CTxOut& txout, tx.vout)
-                txinfo.push_back(txout.ToStringShort());
+            Object entry;
+
+            entry.push_back(Pair("txid", tx.GetHash().GetHex()));
+            TxToJSON(tx, entry);
+            entry.push_back(Pair("time", DateTimeStrFormat(tx.nTime)));
+
+            txinfo.push_back(entry);
         }
         else
             txinfo.push_back(tx.GetHash().GetHex());
     }
+
     result.push_back(Pair("tx", txinfo));
+    result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end())));
+
     return result;
 }
 
@@ -1568,43 +1572,6 @@ Value listsinceblock(const Array& params, bool fHelp)
     return ret;
 }
 
-/*
-Value gettransaction(const Array& params, bool fHelp)
-{
-    if (fHelp || params.size() != 1)
-        throw runtime_error(
-            "gettransaction <txid>\n"
-            "Get detailed information about <txid>");
-
-    uint256 hash;
-    hash.SetHex(params[0].get_str());
-
-    Object entry;
-
-    if (!pwalletMain->mapWallet.count(hash))
-        throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
-    const CWalletTx& wtx = pwalletMain->mapWallet[hash];
-
-    int64 nCredit = wtx.GetCredit();
-    int64 nDebit = wtx.GetDebit();
-    int64 nNet = nCredit - nDebit;
-    int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);
-
-    entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
-    if (wtx.IsFromMe())
-        entry.push_back(Pair("fee", ValueFromAmount(nFee)));
-
-    WalletTxToJSON(pwalletMain->mapWallet[hash], entry);
-
-    Array details;
-    ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details);
-    entry.push_back(Pair("details", details));
-
-    return entry;
-}
-*/
-
-
 Value gettransaction(const Array& params, bool fHelp)
 {
     if (fHelp || params.size() != 1)
@@ -1658,6 +1625,7 @@ Value gettransaction(const Array& params, bool fHelp)
                     if (pindex->IsInMainChain())
                     {
                         entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight));
+                        entry.push_back(Pair("txntime", (boost::int64_t)tx.nTime));
                         entry.push_back(Pair("time", (boost::int64_t)pindex->nTime));
                     }
                     else
@@ -2115,6 +2083,7 @@ Value getworkex(const Array& params, bool fHelp)
         if (!pblock->SignBlock(*pwalletMain))
             throw JSONRPCError(-100, "Unable to sign block, wallet locked?");
 
+
         return CheckWork(pblock, *pwalletMain, reservekey);
     }
 }
@@ -2518,7 +2487,7 @@ Value getnewpubkey(const Array& params, bool fHelp)
         pwalletMain->TopUpKeyPool();
 
     // Generate a new key that is added to wallet
-    std::vector<unsigned char> newKey = pwalletMain->GenerateNewKey(false);
+    std::vector<unsigned char> newKey = pwalletMain->GenerateNewKey(true);
 
     if(!newKey.size())
         throw JSONRPCError(-12, "Error: Unable to create key");
@@ -2868,7 +2837,7 @@ static const CRPCCommand vRPCCommands[] =
     { "signmessage",            &signmessage,            false },
     { "verifymessage",          &verifymessage,          false },
     { "getwork",                &getwork,                true },
-    { "getworkex",              &getworkex,                true },
+    { "getworkex",              &getworkex,              true },
     { "listaccounts",           &listaccounts,           false },
     { "settxfee",               &settxfee,               false },
     { "getmemorypool",          &getmemorypool,          true },