Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) { | ||||
int confirms = wtx.GetDepthInMainChain(); | int confirms = wtx.GetDepthInMainChain(); | ||||
entry.pushKV("confirmations", confirms); | entry.pushKV("confirmations", confirms); | ||||
if (wtx.IsCoinBase()) { | if (wtx.IsCoinBase()) { | ||||
entry.pushKV("generated", true); | entry.pushKV("generated", true); | ||||
} | } | ||||
if (confirms > 0) { | if (confirms > 0) { | ||||
entry.pushKV("blockhash", wtx.hashBlock.GetHex()); | entry.pushKV("blockhash", wtx.hashBlock.GetHex()); | ||||
entry.pushKV("blockindex", wtx.nIndex); | entry.pushKV("blockindex", wtx.nIndex); | ||||
entry.push_back( | entry.pushKV("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime()); | ||||
Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); | |||||
} else { | } else { | ||||
entry.pushKV("trusted", wtx.IsTrusted()); | entry.pushKV("trusted", wtx.IsTrusted()); | ||||
} | } | ||||
uint256 hash = wtx.GetId(); | uint256 hash = wtx.GetId(); | ||||
entry.pushKV("txid", hash.GetHex()); | entry.pushKV("txid", hash.GetHex()); | ||||
UniValue conflicts(UniValue::VARR); | UniValue conflicts(UniValue::VARR); | ||||
for (const uint256 &conflict : wtx.GetConflicts()) { | for (const uint256 &conflict : wtx.GetConflicts()) { | ||||
conflicts.push_back(conflict.GetHex()); | conflicts.push_back(conflict.GetHex()); | ||||
▲ Show 20 Lines • Show All 1,561 Lines • ▼ Show 20 Lines | if ((!listSent.empty() || nFee != Amount::zero()) && | ||||
(::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { | (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) { | ||||
entry.pushKV("involvesWatchonly", true); | entry.pushKV("involvesWatchonly", true); | ||||
} | } | ||||
entry.pushKV("account", strSentAccount); | entry.pushKV("account", strSentAccount); | ||||
MaybePushAddress(entry, s.destination); | MaybePushAddress(entry, s.destination); | ||||
entry.pushKV("category", "send"); | entry.pushKV("category", "send"); | ||||
entry.pushKV("amount", ValueFromAmount(-s.amount)); | entry.pushKV("amount", ValueFromAmount(-s.amount)); | ||||
if (pwallet->mapAddressBook.count(s.destination)) { | if (pwallet->mapAddressBook.count(s.destination)) { | ||||
entry.push_back( | entry.pushKV("label", | ||||
Pair("label", pwallet->mapAddressBook[s.destination].name)); | pwallet->mapAddressBook[s.destination].name); | ||||
} | } | ||||
entry.pushKV("vout", s.vout); | entry.pushKV("vout", s.vout); | ||||
entry.pushKV("fee", ValueFromAmount(-1 * nFee)); | entry.pushKV("fee", ValueFromAmount(-1 * nFee)); | ||||
if (fLong) { | if (fLong) { | ||||
WalletTxToJSON(wtx, entry); | WalletTxToJSON(wtx, entry); | ||||
} | } | ||||
entry.pushKV("abandoned", wtx.isAbandoned()); | entry.pushKV("abandoned", wtx.isAbandoned()); | ||||
ret.push_back(entry); | ret.push_back(entry); | ||||
▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | static UniValue listaccounts(const Config &config, | ||||
const std::list<CAccountingEntry> &acentries = pwallet->laccentries; | const std::list<CAccountingEntry> &acentries = pwallet->laccentries; | ||||
for (const CAccountingEntry &entry : acentries) { | for (const CAccountingEntry &entry : acentries) { | ||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit; | mapAccountBalances[entry.strAccount] += entry.nCreditDebit; | ||||
} | } | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
for (const std::pair<std::string, Amount> &accountBalance : | for (const std::pair<std::string, Amount> &accountBalance : | ||||
mapAccountBalances) { | mapAccountBalances) { | ||||
ret.push_back( | ret.pushKV(accountBalance.first, | ||||
Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); | ValueFromAmount(accountBalance.second)); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue listsinceblock(const Config &config, | static UniValue listsinceblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
▲ Show 20 Lines • Show All 931 Lines • ▼ Show 20 Lines | static UniValue getwalletinfo(const Config &config, | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys(); | size_t kpExternalSize = pwallet->KeypoolCountExternalKeys(); | ||||
obj.pushKV("walletname", pwallet->GetName()); | obj.pushKV("walletname", pwallet->GetName()); | ||||
obj.pushKV("walletversion", pwallet->GetVersion()); | obj.pushKV("walletversion", pwallet->GetVersion()); | ||||
obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); | obj.pushKV("balance", ValueFromAmount(pwallet->GetBalance())); | ||||
obj.push_back(Pair("unconfirmed_balance", | obj.push_back(Pair("unconfirmed_balance", | ||||
Fabien: dito | |||||
ValueFromAmount(pwallet->GetUnconfirmedBalance()))); | ValueFromAmount(pwallet->GetUnconfirmedBalance()))); | ||||
obj.push_back(Pair("immature_balance", | obj.push_back(Pair("immature_balance", | ||||
FabienAuthorUnsubmitted Not Done Inline Actionsdito Fabien: dito | |||||
ValueFromAmount(pwallet->GetImmatureBalance()))); | ValueFromAmount(pwallet->GetImmatureBalance()))); | ||||
obj.pushKV("txcount", (int)pwallet->mapWallet.size()); | obj.pushKV("txcount", (int)pwallet->mapWallet.size()); | ||||
obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); | obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); | ||||
obj.pushKV("keypoolsize", (int64_t)kpExternalSize); | obj.pushKV("keypoolsize", (int64_t)kpExternalSize); | ||||
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; | CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; | ||||
if (!masterKeyID.IsNull() && pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) { | if (!masterKeyID.IsNull() && pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) { | ||||
obj.push_back( | obj.push_back( | ||||
Pair("keypoolsize_hd_internal", | Pair("keypoolsize_hd_internal", | ||||
▲ Show 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | for (const COutput &out : vecOutputs) { | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
entry.pushKV("txid", out.tx->GetId().GetHex()); | entry.pushKV("txid", out.tx->GetId().GetHex()); | ||||
entry.pushKV("vout", out.i); | entry.pushKV("vout", out.i); | ||||
if (fValidAddress) { | if (fValidAddress) { | ||||
entry.pushKV("address", EncodeDestination(address)); | entry.pushKV("address", EncodeDestination(address)); | ||||
if (pwallet->mapAddressBook.count(address)) { | if (pwallet->mapAddressBook.count(address)) { | ||||
entry.push_back( | entry.pushKV("account", pwallet->mapAddressBook[address].name); | ||||
Pair("account", pwallet->mapAddressBook[address].name)); | |||||
} | } | ||||
if (scriptPubKey.IsPayToScriptHash()) { | if (scriptPubKey.IsPayToScriptHash()) { | ||||
const CScriptID &hash = boost::get<CScriptID>(address); | const CScriptID &hash = boost::get<CScriptID>(address); | ||||
CScript redeemScript; | CScript redeemScript; | ||||
if (pwallet->GetCScript(hash, redeemScript)) { | if (pwallet->GetCScript(hash, redeemScript)) { | ||||
entry.push_back( | entry.push_back( | ||||
FabienAuthorUnsubmitted Not Done Inline Actionsdito Fabien: dito | |||||
Pair("redeemScript", | Pair("redeemScript", | ||||
HexStr(redeemScript.begin(), redeemScript.end()))); | HexStr(redeemScript.begin(), redeemScript.end()))); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
entry.push_back(Pair("scriptPubKey", | entry.push_back(Pair("scriptPubKey", | ||||
FabienAuthorUnsubmitted Not Done Inline Actionsdito Fabien: dito | |||||
HexStr(scriptPubKey.begin(), scriptPubKey.end()))); | HexStr(scriptPubKey.begin(), scriptPubKey.end()))); | ||||
entry.push_back( | entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)); | ||||
Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue))); | |||||
entry.pushKV("confirmations", out.nDepth); | entry.pushKV("confirmations", out.nDepth); | ||||
entry.pushKV("spendable", out.fSpendable); | entry.pushKV("spendable", out.fSpendable); | ||||
entry.pushKV("solvable", out.fSolvable); | entry.pushKV("solvable", out.fSolvable); | ||||
entry.pushKV("safe", out.fSafe); | entry.pushKV("safe", out.fSafe); | ||||
results.push_back(entry); | results.push_back(entry); | ||||
} | } | ||||
return results; | return results; | ||||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |
dito