Skip to content

Commit fa4435e

Browse files
author
MarcoFalke
committed
Replace boost::optional with std::optional
1 parent fa7e803 commit fa4435e

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

src/bench/wallet_balance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
3636
if (add_watchonly) importaddress(wallet, ADDRESS_WATCHONLY);
3737

3838
for (int i = 0; i < 100; ++i) {
39-
generatetoaddress(test_setup.m_node, address_mine.get_value_or(ADDRESS_WATCHONLY));
39+
generatetoaddress(test_setup.m_node, address_mine.value_or(ADDRESS_WATCHONLY));
4040
generatetoaddress(test_setup.m_node, ADDRESS_WATCHONLY);
4141
}
4242
SyncWithValidationInterfaceQueue();

src/optional.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
#ifndef BITCOIN_OPTIONAL_H
66
#define BITCOIN_OPTIONAL_H
77

8+
#include <optional>
89
#include <utility>
910

10-
#include <boost/optional.hpp>
11-
1211
//! Substitute for C++17 std::optional
12+
//! DEPRECATED use std::optional in new code.
1313
template <typename T>
14-
using Optional = boost::optional<T>;
14+
using Optional = std::optional<T>;
1515

1616
//! Substitute for C++17 std::nullopt
17-
static auto& nullopt = boost::none;
17+
//! DEPRECATED use std::nullopt in new code.
18+
static auto& nullopt = std::nullopt;
1819

1920
#endif // BITCOIN_OPTIONAL_H

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
231231
// Write back transaction
232232
mtx = CMutableTransaction(*tx_new);
233233
// Mark new tx not replaceable, if requested.
234-
if (!coin_control.m_signal_bip125_rbf.get_value_or(wallet.m_signal_rbf)) {
234+
if (!coin_control.m_signal_bip125_rbf.value_or(wallet.m_signal_rbf)) {
235235
for (auto& input : mtx.vin) {
236236
if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
237237
}

src/wallet/fees.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CFeeRate GetMinimumFeeRate(const CWallet& wallet, const CCoinControl& coin_contr
4949
// We will use smart fee estimation
5050
unsigned int target = coin_control.m_confirm_target ? *coin_control.m_confirm_target : wallet.m_confirm_target;
5151
// By default estimates are economical iff we are signaling opt-in-RBF
52-
bool conservative_estimate = !coin_control.m_signal_bip125_rbf.get_value_or(wallet.m_signal_rbf);
52+
bool conservative_estimate = !coin_control.m_signal_bip125_rbf.value_or(wallet.m_signal_rbf);
5353
// Allow to override the default fee estimate mode over the CoinControl instance
5454
if (coin_control.m_fee_mode == FeeEstimateMode::CONSERVATIVE) conservative_estimate = true;
5555
else if (coin_control.m_fee_mode == FeeEstimateMode::ECONOMICAL) conservative_estimate = false;

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static RPCHelpMan getrawchangeaddress()
309309
throw JSONRPCError(RPC_WALLET_ERROR, "Error: This wallet has no available keys");
310310
}
311311

312-
OutputType output_type = pwallet->m_default_change_type.get_value_or(pwallet->m_default_address_type);
312+
OutputType output_type = pwallet->m_default_change_type.value_or(pwallet->m_default_address_type);
313313
if (!request.params[0].isNull()) {
314314
if (!ParseOutputType(request.params[0].get_str(), output_type)) {
315315
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ static void UpdateWalletSetting(interfaces::Chain& chain,
8585
std::vector<bilingual_str>& warnings)
8686
{
8787
if (load_on_startup == nullopt) return;
88-
if (load_on_startup.get() && !AddWalletSetting(chain, wallet_name)) {
88+
if (load_on_startup.value() && !AddWalletSetting(chain, wallet_name)) {
8989
warnings.emplace_back(Untranslated("Wallet load on startup setting could not be updated, so wallet may not be loaded next node startup."));
90-
} else if (!load_on_startup.get() && !RemoveWalletSetting(chain, wallet_name)) {
90+
} else if (!load_on_startup.value() && !RemoveWalletSetting(chain, wallet_name)) {
9191
warnings.emplace_back(Untranslated("Wallet load on startup setting could not be updated, so wallet may still be loaded next node startup."));
9292
}
9393
}
@@ -3051,7 +3051,7 @@ bool CWallet::CreateTransactionInternal(
30513051
// to avoid conflicting with other possible uses of nSequence,
30523052
// and in the spirit of "smallest possible change from prior
30533053
// behavior."
3054-
const uint32_t nSequence = coin_control.m_signal_bip125_rbf.get_value_or(m_signal_rbf) ? MAX_BIP125_RBF_SEQUENCE : (CTxIn::SEQUENCE_FINAL - 1);
3054+
const uint32_t nSequence = coin_control.m_signal_bip125_rbf.value_or(m_signal_rbf) ? MAX_BIP125_RBF_SEQUENCE : (CTxIn::SEQUENCE_FINAL - 1);
30553055
for (const auto& coin : selected_coins) {
30563056
txNew.vin.push_back(CTxIn(coin.outpoint, CScript(), nSequence));
30573057
}

test/lint/lint-includes.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ EXPECTED_BOOST_INCLUDES=(
6060
boost/multi_index/ordered_index.hpp
6161
boost/multi_index/sequenced_index.hpp
6262
boost/multi_index_container.hpp
63-
boost/optional.hpp
6463
boost/preprocessor/cat.hpp
6564
boost/preprocessor/stringize.hpp
6665
boost/process.hpp

0 commit comments

Comments
 (0)