mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 22:24:05 +01:00
Merge bitcoin/bitcoin#25734: wallet, refactor: #24584 follow-ups
8cd21bb279refactor: improve readability for AttemptSelection (josibake)f47ff71761test: only run test for descriptor wallets (josibake)0760ce0b9etest: add missing BOOST_ASSERT (josibake)db09aec937wallet: switch to new shuffle, erase, push_back (josibake)b6b50b0f2bscripted-diff: Uppercase function names (josibake)3f27a2adcerefactor: add new helper methods (josibake)f5649db9d5refactor: add UNKNOWN OutputType (josibake) Pull request description: This PR is to address follow-ups for #24584, specifically: * Remove redundant, hard-to-read code by adding a new `OutputType` and adding shuffle, erase, and push_back methods for `CoinsResult` * Add missing `BOOST_ASSERT` to unit test * Ensure functional test only runs if using descriptor wallets * Improve readability of `AttemptSelection` by removing triple-nested if statement Note for reviewers: commit `refactor: add new helper methods` should throw an "unused function warning"; the function is used in the next commit. Also, commit `wallet: switch to new shuffle, erase, push_back` will fail to compile, but this is fixed in the next commit with a scripted-diff. the commits are separate like this (code change then scripted-diff) to improve legibility. ACKs for top commit: achow101: ACK8cd21bb279aureleoules: ACK8cd21bb279. LarryRuane: Concept, code review ACK8cd21bb279furszy: utACK8cd21bb2. Left a small, non-blocking, comment. Tree-SHA512: a1bbc5962833e3df4f01a4895d8bd748cc4c608c3f296fd94e8afd8797b8d2e94e7bd44d598bd76fa5c9f5536864f396fcd097348fa0bb190a49a86b0917d60e
This commit is contained in:
@@ -20,6 +20,7 @@ static const std::string OUTPUT_TYPE_STRING_LEGACY = "legacy";
|
||||
static const std::string OUTPUT_TYPE_STRING_P2SH_SEGWIT = "p2sh-segwit";
|
||||
static const std::string OUTPUT_TYPE_STRING_BECH32 = "bech32";
|
||||
static const std::string OUTPUT_TYPE_STRING_BECH32M = "bech32m";
|
||||
static const std::string OUTPUT_TYPE_STRING_UNKNOWN = "unknown";
|
||||
|
||||
std::optional<OutputType> ParseOutputType(const std::string& type)
|
||||
{
|
||||
@@ -31,6 +32,8 @@ std::optional<OutputType> ParseOutputType(const std::string& type)
|
||||
return OutputType::BECH32;
|
||||
} else if (type == OUTPUT_TYPE_STRING_BECH32M) {
|
||||
return OutputType::BECH32M;
|
||||
} else if (type == OUTPUT_TYPE_STRING_UNKNOWN) {
|
||||
return OutputType::UNKNOWN;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -42,6 +45,7 @@ const std::string& FormatOutputType(OutputType type)
|
||||
case OutputType::P2SH_SEGWIT: return OUTPUT_TYPE_STRING_P2SH_SEGWIT;
|
||||
case OutputType::BECH32: return OUTPUT_TYPE_STRING_BECH32;
|
||||
case OutputType::BECH32M: return OUTPUT_TYPE_STRING_BECH32M;
|
||||
case OutputType::UNKNOWN: return OUTPUT_TYPE_STRING_UNKNOWN;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}
|
||||
@@ -61,7 +65,8 @@ CTxDestination GetDestinationForKey(const CPubKey& key, OutputType type)
|
||||
return witdest;
|
||||
}
|
||||
}
|
||||
case OutputType::BECH32M: {} // This function should never be used with BECH32M, so let it assert
|
||||
case OutputType::BECH32M:
|
||||
case OutputType::UNKNOWN: {} // This function should never be used with BECH32M or UNKNOWN, so let it assert
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}
|
||||
@@ -99,7 +104,8 @@ CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore,
|
||||
return ScriptHash(witprog);
|
||||
}
|
||||
}
|
||||
case OutputType::BECH32M: {} // This function should not be used for BECH32M, so let it assert
|
||||
case OutputType::BECH32M:
|
||||
case OutputType::UNKNOWN: {} // This function should not be used for BECH32M or UNKNOWN, so let it assert
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user