Repository: bitcoin/bitcoin
File: src/wallet/coincontrol.h (C/C++)

Code before:
    void SetInputWeight(int64_t weight) { m_weight = weight; }
    std::optional<int64_t> GetInputWeight() const
    {
        return m_weight;
    }

    void SetSequence(uint32_t sequence) { m_sequence = sequence; }
    std::optional<uint32_t> GetSequence() const
    {
        return m_sequence;
    }

    void SetScriptSig(const CScript& script) { m_script_sig = script; }
    void SetScriptWitness(const CScriptWitness& script_wit) { m_script_witness = script_wit; }
    bool HasScripts() const { return m_script_sig.has_value() || m_script_witness.has_value(); }
    std::pair<CScript, CScriptWitness> GetScripts() const
    {
        CScript script_sig;
        if (m_script_sig.has_value()) {
            script_sig = m_script_sig.value();
        }
        CScriptWitness script_witness;
        if (m_script_witness.has_value()) {
            script_witness = m_script_witness.value();
        }
        return {script_sig, script_witness};
    }
};

/** Coin Control Features. */
class CCoinControl
{
public:
    //! Custom change destination, if not set an address is generated
    CTxDestination destChange = CNoDestination();
    //! Override the default change type if set, ignored if destChange is set
    std::optional<OutputType> m_change_type;
    //! If false, only safe inputs will be used
    bool m_include_unsafe_inputs = false;
    //! If true, the selection process can add extra unselected inputs from the wallet
    //! while requires all selected inputs be used
    bool m_allow_other_inputs = true;
    //! Includes watch only addresses which are solvable
    bool fAllowWatchOnly = false;
    //! Override automatic min/max checks on fee, m_feerate must be set if true
    bool fOverrideFeeRate = false;
    //! Override the wallet's m_pay_tx_fee if set
    std::optional<CFeeRate> m_feerate;
    //! Override the default confirmation target if set
    std::optional<unsigned int> m_confirm_target;
    //! Override the wallet's m_signal_rbf if set

Review comment (refactor):
(in commit bf275f358a5e816cf9a8ab6e7dbd39f6dcdf80d7) nit: this could just be a one-liner using [std::optional<T>::value_or](https://en.cppreference.com/w/cpp/utility/optional/value_or)
```suggestion
        return {m_script_sig.value_or(CScript{}), m_script_witness.value_or(CScriptWitness{})};
```

Code after:
    /** Return whether the previous output is set for this input. */
    bool HasTxOut() const;

    /** Set the weight for this input. */
    void SetInputWeight(int64_t weight);
    /** Retrieve the input weight for this input. */
    std::optional<int64_t> GetInputWeight() const;

    /** Set the sequence for this input. */
    void SetSequence(uint32_t sequence);
    /** Retrieve the sequence for this input. */
    std::optional<uint32_t> GetSequence() const;

    /** Set the scriptSig for this input. */
    void SetScriptSig(const CScript& script);
    /** Set the scriptWitness for this input. */
    void SetScriptWitness(const CScriptWitness& script_wit);
    /** Return whether either the scriptSig or scriptWitness are set for this input. */
    bool HasScripts() const;
    /** Retrieve both the scriptSig and the scriptWitness. */
    std::pair<std::optional<CScript>, std::optional<CScriptWitness>> GetScripts() const;

    /** Store the position of this input. */
    void SetPosition(unsigned int pos);
    /** Retrieve the position of this input. */
    std::optional<unsigned int> GetPosition() const;
};

/** Coin Control Features. */
class CCoinControl
{
public:
    //! Custom change destination, if not set an address is generated
    CTxDestination destChange = CNoDestination();
    //! Override the default change type if set, ignored if destChange is set
    std::optional<OutputType> m_change_type;
    //! If false, only safe inputs will be used
    bool m_include_unsafe_inputs = false;
    //! If true, the selection process can add extra unselected inputs from the wallet
    //! while requires all selected inputs be used
    bool m_allow_other_inputs = true;
    //! Includes watch only addresses which are solvable
    bool fAllowWatchOnly = false;
    //! Override automatic min/max checks on fee, m_feerate must be set if true
    bool fOverrideFeeRate = false;
    //! Override the wallet's m_pay_tx_fee if set
    std::optional<CFeeRate> m_feerate;
    //! Override the default confirmation target if set
    std::optional<unsigned int> m_confirm_target;
    //! Override the wallet's m_signal_rbf if set
    std::optional<bool> m_signal_bip125_rbf;