|
|
@ -68,7 +68,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry) |
|
|
|
} |
|
|
|
} |
|
|
|
uint256 hash = wtx.GetHash(); |
|
|
|
uint256 hash = wtx.GetHash(); |
|
|
|
entry.push_back(Pair("txid", hash.GetHex())); |
|
|
|
entry.push_back(Pair("txid", hash.GetHex())); |
|
|
|
Array conflicts; |
|
|
|
UniValue conflicts(UniValue::VARR); |
|
|
|
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) |
|
|
|
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) |
|
|
|
conflicts.push_back(conflict.GetHex()); |
|
|
|
conflicts.push_back(conflict.GetHex()); |
|
|
|
entry.push_back(Pair("walletconflicts", conflicts)); |
|
|
|
entry.push_back(Pair("walletconflicts", conflicts)); |
|
|
@ -336,7 +336,7 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) |
|
|
|
string strAccount = AccountFromValue(params[0]); |
|
|
|
string strAccount = AccountFromValue(params[0]); |
|
|
|
|
|
|
|
|
|
|
|
// Find all addresses that have the given account
|
|
|
|
// Find all addresses that have the given account
|
|
|
|
Array ret; |
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CBitcoinAddress& address = item.first; |
|
|
|
const CBitcoinAddress& address = item.first; |
|
|
@ -464,14 +464,14 @@ Value listaddressgroupings(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
|
|
|
|
|
|
|
|
Array jsonGroupings; |
|
|
|
UniValue jsonGroupings(UniValue::VARR); |
|
|
|
map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances(); |
|
|
|
map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances(); |
|
|
|
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings()) |
|
|
|
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Array jsonGrouping; |
|
|
|
UniValue jsonGrouping(UniValue::VARR); |
|
|
|
BOOST_FOREACH(CTxDestination address, grouping) |
|
|
|
BOOST_FOREACH(CTxDestination address, grouping) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Array addressInfo; |
|
|
|
UniValue addressInfo(UniValue::VARR); |
|
|
|
addressInfo.push_back(CBitcoinAddress(address).ToString()); |
|
|
|
addressInfo.push_back(CBitcoinAddress(address).ToString()); |
|
|
|
addressInfo.push_back(ValueFromAmount(balances[address])); |
|
|
|
addressInfo.push_back(ValueFromAmount(balances[address])); |
|
|
|
{ |
|
|
|
{ |
|
|
@ -967,7 +967,7 @@ Value sendmany(const Array& params, bool fHelp) |
|
|
|
if (params.size() > 3 && !params[3].isNull() && !params[3].get_str().empty()) |
|
|
|
if (params.size() > 3 && !params[3].isNull() && !params[3].get_str().empty()) |
|
|
|
wtx.mapValue["comment"] = params[3].get_str(); |
|
|
|
wtx.mapValue["comment"] = params[3].get_str(); |
|
|
|
|
|
|
|
|
|
|
|
Array subtractFeeFromAmount; |
|
|
|
UniValue subtractFeeFromAmount(UniValue::VARR); |
|
|
|
if (params.size() > 4) |
|
|
|
if (params.size() > 4) |
|
|
|
subtractFeeFromAmount = params[4].get_array(); |
|
|
|
subtractFeeFromAmount = params[4].get_array(); |
|
|
|
|
|
|
|
|
|
|
@ -1138,7 +1138,7 @@ Value ListReceived(const Array& params, bool fByAccounts) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Reply
|
|
|
|
// Reply
|
|
|
|
Array ret; |
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
map<string, tallyitem> mapAccountTally; |
|
|
|
map<string, tallyitem> mapAccountTally; |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1167,14 +1167,14 @@ Value ListReceived(const Array& params, bool fByAccounts) |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object obj; |
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
if(fIsWatchonly) |
|
|
|
if(fIsWatchonly) |
|
|
|
obj.push_back(Pair("involvesWatchonly", true)); |
|
|
|
obj.push_back(Pair("involvesWatchonly", true)); |
|
|
|
obj.push_back(Pair("address", address.ToString())); |
|
|
|
obj.push_back(Pair("address", address.ToString())); |
|
|
|
obj.push_back(Pair("account", strAccount)); |
|
|
|
obj.push_back(Pair("account", strAccount)); |
|
|
|
obj.push_back(Pair("amount", ValueFromAmount(nAmount))); |
|
|
|
obj.push_back(Pair("amount", ValueFromAmount(nAmount))); |
|
|
|
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); |
|
|
|
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); |
|
|
|
Array transactions; |
|
|
|
UniValue transactions(UniValue::VARR); |
|
|
|
if (it != mapTally.end()) |
|
|
|
if (it != mapTally.end()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const uint256& item, (*it).second.txids) |
|
|
|
BOOST_FOREACH(const uint256& item, (*it).second.txids) |
|
|
@ -1193,7 +1193,7 @@ Value ListReceived(const Array& params, bool fByAccounts) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAmount nAmount = (*it).second.nAmount; |
|
|
|
CAmount nAmount = (*it).second.nAmount; |
|
|
|
int nConf = (*it).second.nConf; |
|
|
|
int nConf = (*it).second.nConf; |
|
|
|
Object obj; |
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
if((*it).second.fIsWatchonly) |
|
|
|
if((*it).second.fIsWatchonly) |
|
|
|
obj.push_back(Pair("involvesWatchonly", true)); |
|
|
|
obj.push_back(Pair("involvesWatchonly", true)); |
|
|
|
obj.push_back(Pair("account", (*it).first)); |
|
|
|
obj.push_back(Pair("account", (*it).first)); |
|
|
@ -1303,7 +1303,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const COutputEntry& s, listSent) |
|
|
|
BOOST_FOREACH(const COutputEntry& s, listSent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
UniValue entry(UniValue::VOBJ); |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
|
entry.push_back(Pair("account", strSentAccount)); |
|
|
@ -1328,7 +1328,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe |
|
|
|
account = pwalletMain->mapAddressBook[r.destination].name; |
|
|
|
account = pwalletMain->mapAddressBook[r.destination].name; |
|
|
|
if (fAllAccounts || (account == strAccount)) |
|
|
|
if (fAllAccounts || (account == strAccount)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
UniValue entry(UniValue::VOBJ); |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("involvesWatchonly", true)); |
|
|
|
entry.push_back(Pair("account", account)); |
|
|
|
entry.push_back(Pair("account", account)); |
|
|
@ -1362,7 +1362,7 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar |
|
|
|
|
|
|
|
|
|
|
|
if (fAllAccounts || acentry.strAccount == strAccount) |
|
|
|
if (fAllAccounts || acentry.strAccount == strAccount) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object entry; |
|
|
|
UniValue entry(UniValue::VOBJ); |
|
|
|
entry.push_back(Pair("account", acentry.strAccount)); |
|
|
|
entry.push_back(Pair("account", acentry.strAccount)); |
|
|
|
entry.push_back(Pair("category", "move")); |
|
|
|
entry.push_back(Pair("category", "move")); |
|
|
|
entry.push_back(Pair("time", acentry.nTime)); |
|
|
|
entry.push_back(Pair("time", acentry.nTime)); |
|
|
@ -1451,7 +1451,7 @@ Value listtransactions(const Array& params, bool fHelp) |
|
|
|
if (nFrom < 0) |
|
|
|
if (nFrom < 0) |
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from"); |
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from"); |
|
|
|
|
|
|
|
|
|
|
|
Array ret; |
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
|
|
|
|
|
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
|
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount); |
|
|
|
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount); |
|
|
@ -1488,6 +1488,7 @@ Value listtransactions(const Array& params, bool fHelp) |
|
|
|
std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest
|
|
|
|
std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest
|
|
|
|
|
|
|
|
|
|
|
|
ret.clear(); |
|
|
|
ret.clear(); |
|
|
|
|
|
|
|
ret.setArray(); |
|
|
|
ret.push_backV(arrTmp); |
|
|
|
ret.push_backV(arrTmp); |
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
@ -1566,7 +1567,7 @@ Value listaccounts(const Array& params, bool fHelp) |
|
|
|
BOOST_FOREACH(const CAccountingEntry& entry, acentries) |
|
|
|
BOOST_FOREACH(const CAccountingEntry& entry, acentries) |
|
|
|
mapAccountBalances[entry.strAccount] += entry.nCreditDebit; |
|
|
|
mapAccountBalances[entry.strAccount] += entry.nCreditDebit; |
|
|
|
|
|
|
|
|
|
|
|
Object ret; |
|
|
|
UniValue ret(UniValue::VOBJ); |
|
|
|
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) { |
|
|
|
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) { |
|
|
|
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); |
|
|
|
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); |
|
|
|
} |
|
|
|
} |
|
|
@ -1644,7 +1645,7 @@ Value listsinceblock(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1; |
|
|
|
int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1; |
|
|
|
|
|
|
|
|
|
|
|
Array transactions; |
|
|
|
UniValue transactions(UniValue::VARR); |
|
|
|
|
|
|
|
|
|
|
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) |
|
|
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1657,7 +1658,7 @@ Value listsinceblock(const Array& params, bool fHelp) |
|
|
|
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms]; |
|
|
|
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms]; |
|
|
|
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); |
|
|
|
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); |
|
|
|
|
|
|
|
|
|
|
|
Object ret; |
|
|
|
UniValue ret(UniValue::VOBJ); |
|
|
|
ret.push_back(Pair("transactions", transactions)); |
|
|
|
ret.push_back(Pair("transactions", transactions)); |
|
|
|
ret.push_back(Pair("lastblock", lastblock.GetHex())); |
|
|
|
ret.push_back(Pair("lastblock", lastblock.GetHex())); |
|
|
|
|
|
|
|
|
|
|
@ -1715,7 +1716,7 @@ Value gettransaction(const Array& params, bool fHelp) |
|
|
|
if(params[1].get_bool()) |
|
|
|
if(params[1].get_bool()) |
|
|
|
filter = filter | ISMINE_WATCH_ONLY; |
|
|
|
filter = filter | ISMINE_WATCH_ONLY; |
|
|
|
|
|
|
|
|
|
|
|
Object entry; |
|
|
|
UniValue entry(UniValue::VOBJ); |
|
|
|
if (!pwalletMain->mapWallet.count(hash)) |
|
|
|
if (!pwalletMain->mapWallet.count(hash)) |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); |
|
|
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); |
|
|
|
const CWalletTx& wtx = pwalletMain->mapWallet[hash]; |
|
|
|
const CWalletTx& wtx = pwalletMain->mapWallet[hash]; |
|
|
@ -1731,7 +1732,7 @@ Value gettransaction(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
WalletTxToJSON(wtx, entry); |
|
|
|
|
|
|
|
|
|
|
|
Array details; |
|
|
|
UniValue details(UniValue::VARR); |
|
|
|
ListTransactions(wtx, "*", 0, false, details, filter); |
|
|
|
ListTransactions(wtx, "*", 0, false, details, filter); |
|
|
|
entry.push_back(Pair("details", details)); |
|
|
|
entry.push_back(Pair("details", details)); |
|
|
|
|
|
|
|
|
|
|
@ -2134,10 +2135,10 @@ Value listlockunspent(const Array& params, bool fHelp) |
|
|
|
vector<COutPoint> vOutpts; |
|
|
|
vector<COutPoint> vOutpts; |
|
|
|
pwalletMain->ListLockedCoins(vOutpts); |
|
|
|
pwalletMain->ListLockedCoins(vOutpts); |
|
|
|
|
|
|
|
|
|
|
|
Array ret; |
|
|
|
UniValue ret(UniValue::VARR); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(COutPoint &outpt, vOutpts) { |
|
|
|
BOOST_FOREACH(COutPoint &outpt, vOutpts) { |
|
|
|
Object o; |
|
|
|
UniValue o(UniValue::VOBJ); |
|
|
|
|
|
|
|
|
|
|
|
o.push_back(Pair("txid", outpt.hash.GetHex())); |
|
|
|
o.push_back(Pair("txid", outpt.hash.GetHex())); |
|
|
|
o.push_back(Pair("vout", (int)outpt.n)); |
|
|
|
o.push_back(Pair("vout", (int)outpt.n)); |
|
|
@ -2203,7 +2204,7 @@ Value getwalletinfo(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
|
|
|
|
|
|
|
|
Object obj; |
|
|
|
UniValue obj(UniValue::VOBJ); |
|
|
|
obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); |
|
|
|
obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); |
|
|
|
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); |
|
|
|
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); |
|
|
|
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); |
|
|
|
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); |
|
|
@ -2233,7 +2234,7 @@ Value resendwallettransactions(const Array& params, bool fHelp) |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
|
|
|
|
|
|
|
|
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime()); |
|
|
|
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime()); |
|
|
|
Array result; |
|
|
|
UniValue result(UniValue::VARR); |
|
|
|
BOOST_FOREACH(const uint256& txid, txids) |
|
|
|
BOOST_FOREACH(const uint256& txid, txids) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result.push_back(txid.ToString()); |
|
|
|
result.push_back(txid.ToString()); |
|
|
@ -2306,7 +2307,7 @@ Value listunspent(const Array& params, bool fHelp) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Array results; |
|
|
|
UniValue results(UniValue::VARR); |
|
|
|
vector<COutput> vecOutputs; |
|
|
|
vector<COutput> vecOutputs; |
|
|
|
assert(pwalletMain != NULL); |
|
|
|
assert(pwalletMain != NULL); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
|
LOCK2(cs_main, pwalletMain->cs_wallet); |
|
|
@ -2326,7 +2327,7 @@ Value listunspent(const Array& params, bool fHelp) |
|
|
|
|
|
|
|
|
|
|
|
CAmount nValue = out.tx->vout[out.i].nValue; |
|
|
|
CAmount nValue = out.tx->vout[out.i].nValue; |
|
|
|
const CScript& pk = out.tx->vout[out.i].scriptPubKey; |
|
|
|
const CScript& pk = out.tx->vout[out.i].scriptPubKey; |
|
|
|
Object entry; |
|
|
|
UniValue entry(UniValue::VOBJ); |
|
|
|
entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); |
|
|
|
entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); |
|
|
|
entry.push_back(Pair("vout", out.i)); |
|
|
|
entry.push_back(Pair("vout", out.i)); |
|
|
|
CTxDestination address; |
|
|
|
CTxDestination address; |
|
|
|