Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | if (wtx.IsCoinBase()) { | ||||
entry.pushKV("generated", true); | entry.pushKV("generated", true); | ||||
} | } | ||||
if (confirms > 0) { | if (confirms > 0) { | ||||
entry.pushKV("blockhash", wtx.m_confirm.hashBlock.GetHex()); | entry.pushKV("blockhash", wtx.m_confirm.hashBlock.GetHex()); | ||||
entry.pushKV("blockindex", wtx.m_confirm.nIndex); | entry.pushKV("blockindex", wtx.m_confirm.nIndex); | ||||
int64_t block_time; | int64_t block_time; | ||||
bool found_block = chain.findBlock(wtx.m_confirm.hashBlock, | bool found_block = chain.findBlock(wtx.m_confirm.hashBlock, | ||||
nullptr /* block */, &block_time); | nullptr /* block */, &block_time); | ||||
assert(found_block); | CHECK_NONFATAL(found_block); | ||||
entry.pushKV("blocktime", block_time); | entry.pushKV("blocktime", block_time); | ||||
} else { | } else { | ||||
entry.pushKV("trusted", wtx.IsTrusted(locked_chain)); | entry.pushKV("trusted", wtx.IsTrusted(locked_chain)); | ||||
} | } | ||||
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()) { | ||||
▲ Show 20 Lines • Show All 4,130 Lines • ▼ Show 20 Lines | UniValue getaddressesbylabel(const Config &config, | ||||
for (const std::pair<const CTxDestination, CAddressBookData> &item : | for (const std::pair<const CTxDestination, CAddressBookData> &item : | ||||
pwallet->mapAddressBook) { | pwallet->mapAddressBook) { | ||||
if (item.second.name == label) { | if (item.second.name == label) { | ||||
std::string address = EncodeDestination(item.first, config); | std::string address = EncodeDestination(item.first, config); | ||||
// CWallet::mapAddressBook is not expected to contain duplicate | // CWallet::mapAddressBook is not expected to contain duplicate | ||||
// address strings, but build a separate set as a precaution just in | // address strings, but build a separate set as a precaution just in | ||||
// case it does. | // case it does. | ||||
bool unique = addresses.emplace(address).second; | bool unique = addresses.emplace(address).second; | ||||
assert(unique); | CHECK_NONFATAL(unique); | ||||
// UniValue::pushKV checks if the key exists in O(N) | // UniValue::pushKV checks if the key exists in O(N) | ||||
// and since duplicate addresses are unexpected (checked with | // and since duplicate addresses are unexpected (checked with | ||||
// std::set in O(log(N))), UniValue::__pushKV is used instead, | // std::set in O(log(N))), UniValue::__pushKV is used instead, | ||||
// which currently is O(1). | // which currently is O(1). | ||||
ret.__pushKV(address, AddressBookDataToJSON(item.second, false)); | ret.__pushKV(address, AddressBookDataToJSON(item.second, false)); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 491 Lines • Show Last 20 Lines |