The util::Result class provides a standard way for functions to return either error messages or result values.
Synopsis
Declared in <util/result.h>
template<class M>
class Result;
Description
It is intended for high‐level functions that need to report error strings to end users. Lower‐level functions that don't need this error‐reporting and that only need error‐handling should avoid util::Result and instead use util::Expected, std::optional, std::variant, or custom structs and enum types to return function results.
Usage examples can be found in
general code returning util::Result<T> values is very similar to code returning std::optional<T> values. Existing functions returning std::optional<T> can be updated to return util::Result<T> and return error strings usually just replacing return std::nullopt; with `return util::Error{error_string};`.
Member Functions
Name |
Description |
|
Constructors |
|
Destroys the result and its held value or error message. |
std::optional methods, so functions returning optional<T> can change to return Result<T> with minimal changes to existing code, and vice versa. |
|
Dereferences the held value. |
|
Member access to the held value. |
|
Accesses the held value; asserts that the result holds a value. |
|
|
|
Tests whether the result holds a value. |
Friends
Name |
Description |
Extracts the error message from a result. |
Non-Member Functions
Name |
Description |
Extracts the error message from a result. |
|
Overlay the options set in |
|
Decode a base64‐encoded PSBT into a PartiallySignedTransaction. |
|
Decode a raw binary PSBT into a PartiallySignedTransaction. |
|
Loads the address manager (peers.dat), creating a fresh one if needed. |
|
Parse a signature‐hash type from its textual name. |
|
Enables or disables the debug logging categories selected by the arguments. |
|
Sets the global logging severity level selected by the arguments. |
|
Ensure a usable environment with all necessary library support. |
|
Apply block‐storage options taken from the argument manager. |
|
Apply chainstate‐manager options taken from the argument manager. |
|
Check option values for validity. Returns an error for invalid values. |
|
Read the mining options set in |
|
Attempt to find a valid input set that preserves privacy by not mixing OutputTypes. |
|
Select a set of coins such that nTargetValue is met; never select unconfirmed coins if they are not ours |
|
Attempt to find a valid input set that meets the provided eligibility filter and target. Multiple coin selection algorithms will be run and the input set that produces the least waste (according to the waste metric) will be chosen. |
|
Select coins using the CoinGrinder deterministic search algorithm. |
|
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also create the change output, when needed |
|
Make a new watchonly wallet file containing the public descriptors from this wallet The exported watchonly wallet file will be named and placed at the path specified in 'destination' |
|
Fetch and validate coin control selected inputs. Coins could be internal (from the wallet) or external. |
|
Insert additional inputs into the transaction by calling CreateTransaction(); |
|
Determine the path that the wallet is stored in |
|
Select coins using the original Knapsack approximation, used as a fallback. |
|
Do all steps to migrate a legacy wallet to a descriptor wallet |
|
Requirement: The wallet provided to this function must be isolated, with no attachment to the node's context. |
|
Select all coins from coin_control, and if coin_control 'm_allow_other_inputs=true', call 'AutomaticCoinSelection' to select a set of coins such that nTargetValue ‐ pre_set_inputs.total_amount is met. |
|
Select coins using the Branch and Bound algorithm to find a changeless solution. |
|
Select coins by Single Random Draw (SRD). SRD selects eligible OutputGroups from a shuffled ordering until the effective value of the input set suffices to create the recipient outputs and a change output with an amount of at least CHANGE_LOWER. While the maximum selection weight is exceeded during selection, the OutputGroup with the lowest effective value is dropped from the selection before additional OutputGroups are selected. Due to this greedy approach, SRD can fail to discover possible solutions in pathological cases. |
Created with MrDocs