util::Expected

The util::Expected class provides a standard way for low-level functions to return either error values or result values.

Synopsis

Declared in <util/expected.h>

template<
    class T,
    class E>
class Expected;

Description

It provides a smaller version of std::expected from C++23. Missing features can be added, if needed.

Member Functions

NameDescription
Expected [constructor]Constructors
error Access the stored error (undefined behavior if a value is held).
has_value Test whether a result value is held.
operator* Access the result value without checking.
operator-> Access members of the result value.
swap Swap contents with another Expected.
value Access the result value, throwing if an error is held.
value_or Return the result value, or a fallback when an error is held.
operator bool Test whether a result value is held.

Specializations

Name
Expected<void, E>

Non-Member Functions

NameDescription
::FeeRateEstimationRefReturn the estimation carried by a fee rate estimate result: the successful estimation, or the error's zero-value estimation.
::ParseKeyPathElementParse a single key path element like "0", "0'", or "0h". Returns the derivation index and hardened status, or an error message.
::SignPSBTInputSigns a PSBTInput, verifying that all provided data matches what is being signed.
::wallet::ExportDescriptorsExport the descriptors from a wallet so that they can be imported elsewhere