Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,285 Lines • ▼ Show 20 Lines | static UniValue listsinceblock(const Config &config, | ||||
UniValue removed(UniValue::VARR); | UniValue removed(UniValue::VARR); | ||||
while (include_removed && paltindex && paltindex != pindex) { | while (include_removed && paltindex && paltindex != pindex) { | ||||
CBlock block; | CBlock block; | ||||
if (!ReadBlockFromDisk(block, paltindex, config)) { | if (!ReadBlockFromDisk(block, paltindex, config)) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
"Can't read block from disk"); | "Can't read block from disk"); | ||||
} | } | ||||
for (const CTransactionRef &tx : block.vtx) { | for (const CTransactionRef &tx : block.vtx) { | ||||
if (pwallet->mapWallet.count(tx->GetId()) > 0) { | auto it = pwallet->mapWallet.find(tx->GetId()); | ||||
if (it != pwallet->mapWallet.end()) { | |||||
// We want all transactions regardless of confirmation count to | // We want all transactions regardless of confirmation count to | ||||
// appear here, even negative confirmation ones, hence the big | // appear here, even negative confirmation ones, hence the big | ||||
// negative. | // negative. | ||||
ListTransactions(pwallet, pwallet->mapWallet.at(tx->GetId()), | ListTransactions(pwallet, it->second, "*", -100000000, true, | ||||
"*", -100000000, true, removed, filter); | removed, filter); | ||||
} | } | ||||
} | } | ||||
paltindex = paltindex->pprev; | paltindex = paltindex->pprev; | ||||
} | } | ||||
CBlockIndex *pblockLast = | CBlockIndex *pblockLast = | ||||
chainActive[chainActive.Height() + 1 - target_confirms]; | chainActive[chainActive.Height() + 1 - target_confirms]; | ||||
uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); | uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | static UniValue gettransaction(const Config &config, | ||||
txid.SetHex(request.params[0].get_str()); | txid.SetHex(request.params[0].get_str()); | ||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
if (!request.params[1].isNull() && request.params[1].get_bool()) { | if (!request.params[1].isNull() && request.params[1].get_bool()) { | ||||
filter = filter | ISMINE_WATCH_ONLY; | filter = filter | ISMINE_WATCH_ONLY; | ||||
} | } | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
if (!pwallet->mapWallet.count(txid)) { | auto it = pwallet->mapWallet.find(txid); | ||||
if (it == pwallet->mapWallet.end()) { | |||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid or non-wallet transaction id"); | "Invalid or non-wallet transaction id"); | ||||
} | } | ||||
const CWalletTx &wtx = it->second; | |||||
const CWalletTx &wtx = pwallet->mapWallet.at(txid); | |||||
Amount nCredit = wtx.GetCredit(filter); | Amount nCredit = wtx.GetCredit(filter); | ||||
Amount nDebit = wtx.GetDebit(filter); | Amount nDebit = wtx.GetDebit(filter); | ||||
Amount nNet = nCredit - nDebit; | Amount nNet = nCredit - nDebit; | ||||
Amount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit | Amount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit | ||||
: Amount::zero()); | : Amount::zero()); | ||||
entry.pushKV("amount", ValueFromAmount(nNet - nFee)); | entry.pushKV("amount", ValueFromAmount(nNet - nFee)); | ||||
▲ Show 20 Lines • Show All 1,523 Lines • Show Last 20 Lines |