mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Merge #18946: rpcwallet: Replace boost::optional<T>::emplace with simple assignment of T{}
fa1f840596
rpcwallet: Replace pwallet-> with wallet. (MarcoFalke)fa182a8794
rpcwallet: Replace boost::optional<T>::emplace with simple assignment of T{} (MarcoFalke) Pull request description: Closes #18943 ACKs for top commit: laanwj: ACKfa1f840596
ryanofsky: Code review ACKfa1f840596
and thanks for using a standalone commit for the fix promag: Code review ACKfa1f840596
. hebasto: ACKfa1f840596
, tested on Linux Mint 19.3. Tree-SHA512: 0838485d1f93f737ce5bf12740669dcafeebb78dbc3fa15dbcc511edce64bf024f60f0497a04149a1e799d893d57b0c9ffe442020c1b9cfc3c69db731f50e712
This commit is contained in:
commit
4dd2e5255a
1 changed files with 17 additions and 17 deletions
|
@ -1482,10 +1482,9 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
|||
|
||||
static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
const CWallet* const pwallet = wallet.get();
|
||||
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
if (!EnsureWalletIsAvailable(pwallet.get(), request.fHelp)) {
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
|
@ -1542,11 +1541,12 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
},
|
||||
}.Check(request);
|
||||
|
||||
const CWallet& wallet = *pwallet;
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
wallet.BlockUntilSyncedToCurrentChain();
|
||||
|
||||
LOCK(pwallet->cs_wallet);
|
||||
LOCK(wallet.cs_wallet);
|
||||
|
||||
// The way the 'height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
|
||||
Optional<int> height = MakeOptional(false, int()); // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
|
||||
|
@ -1557,9 +1557,9 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
uint256 blockId;
|
||||
if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
|
||||
blockId = ParseHashV(request.params[0], "blockhash");
|
||||
height.emplace();
|
||||
altheight.emplace();
|
||||
if (!pwallet->chain().findCommonAncestor(blockId, pwallet->GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
|
||||
height = int{};
|
||||
altheight = int{};
|
||||
if (!wallet.chain().findCommonAncestor(blockId, wallet.GetLastBlockHash(), /* ancestor out */ FoundBlock().height(*height), /* blockId out */ FoundBlock().height(*altheight))) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
|
||||
}
|
||||
}
|
||||
|
@ -1572,21 +1572,21 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
}
|
||||
}
|
||||
|
||||
if (ParseIncludeWatchonly(request.params[2], *pwallet)) {
|
||||
if (ParseIncludeWatchonly(request.params[2], wallet)) {
|
||||
filter |= ISMINE_WATCH_ONLY;
|
||||
}
|
||||
|
||||
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
|
||||
|
||||
int depth = height ? pwallet->GetLastBlockHeight() + 1 - *height : -1;
|
||||
int depth = height ? wallet.GetLastBlockHeight() + 1 - *height : -1;
|
||||
|
||||
UniValue transactions(UniValue::VARR);
|
||||
|
||||
for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
|
||||
for (const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
|
||||
const CWalletTx& tx = pairWtx.second;
|
||||
|
||||
if (depth == -1 || abs(tx.GetDepthInMainChain()) < depth) {
|
||||
ListTransactions(pwallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
|
||||
ListTransactions(&wallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1595,15 +1595,15 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
UniValue removed(UniValue::VARR);
|
||||
while (include_removed && altheight && *altheight > *height) {
|
||||
CBlock block;
|
||||
if (!pwallet->chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
|
||||
if (!wallet.chain().findBlock(blockId, FoundBlock().data(block)) || block.IsNull()) {
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||
}
|
||||
for (const CTransactionRef& tx : block.vtx) {
|
||||
auto it = pwallet->mapWallet.find(tx->GetHash());
|
||||
if (it != pwallet->mapWallet.end()) {
|
||||
auto it = wallet.mapWallet.find(tx->GetHash());
|
||||
if (it != wallet.mapWallet.end()) {
|
||||
// We want all transactions regardless of confirmation count to appear here,
|
||||
// even negative confirmation ones, hence the big negative.
|
||||
ListTransactions(pwallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
|
||||
ListTransactions(&wallet, it->second, -100000000, true, removed, filter, nullptr /* filter_label */);
|
||||
}
|
||||
}
|
||||
blockId = block.hashPrevBlock;
|
||||
|
@ -1611,7 +1611,7 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
}
|
||||
|
||||
uint256 lastblock;
|
||||
CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), pwallet->GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
|
||||
CHECK_NONFATAL(wallet.chain().findAncestorByHeight(wallet.GetLastBlockHash(), wallet.GetLastBlockHeight() + 1 - target_confirms, FoundBlock().hash(lastblock)));
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
ret.pushKV("transactions", transactions);
|
||||
|
|
Loading…
Reference in a new issue