aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 8311b39c4e..d3b6c349a7 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
+// Copyright (c) 2009-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -45,13 +45,18 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
entry.push_back(Pair("confirmations", confirms));
if (wtx.IsCoinBase())
entry.push_back(Pair("generated", true));
- if (confirms)
+ if (confirms > 0)
{
entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex()));
entry.push_back(Pair("blockindex", wtx.nIndex));
entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime)));
}
- entry.push_back(Pair("txid", wtx.GetHash().GetHex()));
+ uint256 hash = wtx.GetHash();
+ entry.push_back(Pair("txid", hash.GetHex()));
+ Array conflicts;
+ BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
+ conflicts.push_back(conflict.GetHex());
+ entry.push_back(Pair("walletconflicts", conflicts));
entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));
entry.push_back(Pair("timereceived", (boost::int64_t)wtx.nTimeReceived));
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
@@ -555,7 +560,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
- if (!IsFinalTx(wtx))
+ if (!IsFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0)
continue;
int64_t nReceived, nSent, nFee;
@@ -621,7 +626,7 @@ Value getbalance(const Array& params, bool fHelp)
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
- if (!wtx.IsConfirmed())
+ if (!wtx.IsTrusted() || wtx.GetBlocksToMaturity() > 0)
continue;
int64_t allFee;
@@ -1141,7 +1146,9 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
entry.push_back(Pair("category", "generate"));
}
else
+ {
entry.push_back(Pair("category", "receive"));
+ }
entry.push_back(Pair("amount", ValueFromAmount(r.second)));
if (fLong)
WalletTxToJSON(wtx, entry);
@@ -1317,11 +1324,14 @@ Value listaccounts(const Array& params, bool fHelp)
string strSentAccount;
list<pair<CTxDestination, int64_t> > listReceived;
list<pair<CTxDestination, int64_t> > listSent;
+ int nDepth = wtx.GetDepthInMainChain();
+ if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0)
+ continue;
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount);
mapAccountBalances[strSentAccount] -= nFee;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent)
mapAccountBalances[strSentAccount] -= s.second;
- if (wtx.GetDepthInMainChain() >= nMinDepth)
+ if (nDepth >= nMinDepth)
{
BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived)
if (pwalletMain->mapAddressBook.count(r.first))
@@ -1448,7 +1458,8 @@ Value gettransaction(const Array& params, bool fHelp)
" \"amount\" : x.xxx (numeric) The amount in btc\n"
" }\n"
" ,...\n"
- " ]\n"
+ " ],\n"
+ " \"hex\" : \"data\" (string) Raw data for transaction\n"
"}\n"
"\nbExamples\n"
@@ -1479,6 +1490,11 @@ Value gettransaction(const Array& params, bool fHelp)
ListTransactions(wtx, "*", 0, false, details);
entry.push_back(Pair("details", details));
+ CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
+ ssTx << static_cast<CTransaction>(wtx);
+ string strHex = HexStr(ssTx.begin(), ssTx.end());
+ entry.push_back(Pair("hex", strHex));
+
return entry;
}
@@ -1553,6 +1569,9 @@ Value walletpassphrase(const Array& params, bool fHelp)
"\nArguments:\n"
"1. \"passphrase\" (string, required) The wallet passphrase\n"
"2. timeout (numeric, required) The time to keep the decryption key in seconds.\n"
+ "\nNote:\n"
+ "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n"
+ "time that overrides the old one.\n"
"\nExamples:\n"
"\nunlock the wallet for 60 seconds\n"
+ HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") +
@@ -1850,9 +1869,9 @@ Value settxfee(const Array& params, bool fHelp)
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
"settxfee amount\n"
- "\nSet the transaction fee per KB.\n"
+ "\nSet the transaction fee per kB.\n"
"\nArguments:\n"
- "1. amount (numeric, required) The transaction fee in BTC/KB rounded to the nearest 0.00000001\n"
+ "1. amount (numeric, required) The transaction fee in BTC/kB rounded to the nearest 0.00000001\n"
"\nResult\n"
"true|false (boolean) Returns true if successful\n"
"\nExamples:\n"