mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +02:00
codex32: provide user-readable error types
Github-Pull: #27351 Rebased-From: 1fa04b11b2452a2f15906d97cf1370d43f0dc23e
This commit is contained in:
parent
3110257f5a
commit
c85de09d88
@ -220,6 +220,26 @@ uint8_t lagrange_coefficient(std::vector<uint8_t>& indices, uint8_t idx, uint8_t
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
std::string ErrorString(Error e) {
|
||||||
|
switch (e) {
|
||||||
|
case OK: return "ok";
|
||||||
|
case BAD_CHECKSUM: return "bad checksum";
|
||||||
|
case BECH32_DECODE: return "bech32 decode failure (invalid character, no HRP, or inconsistent case)";
|
||||||
|
case INVALID_HRP: return "hrp differed from 'ms'";
|
||||||
|
case INVALID_ID_LEN: return "seed ID was not 4 characters";
|
||||||
|
case INVALID_ID_CHAR: return "seed ID used a non-bech32 character";
|
||||||
|
case INVALID_LENGTH: return "invalid length";
|
||||||
|
case INVALID_K: return "invalid threshold (k) value";
|
||||||
|
case INVALID_SHARE_IDX: return "invalid share index";
|
||||||
|
case TOO_FEW_SHARES: return "tried to derive a share but did not have enough input shares";
|
||||||
|
case DUPLICATE_SHARE: return "tried to derive a share but two input shares had the same index";
|
||||||
|
case MISMATCH_K: return "tried to derive a share but input shares had inconsistent threshold (k) values";
|
||||||
|
case MISMATCH_ID: return "tried to derive a share but input shares had inconsistent seed IDs";
|
||||||
|
case MISMATCH_LENGTH: return "tried to derive a share but input shares had inconsistent lengths";
|
||||||
|
}
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
/** Encode a codex32 string. */
|
/** Encode a codex32 string. */
|
||||||
std::string Result::Encode() const {
|
std::string Result::Encode() const {
|
||||||
assert(IsValid());
|
assert(IsValid());
|
||||||
|
@ -41,6 +41,8 @@ enum Error {
|
|||||||
MISMATCH_LENGTH,
|
MISMATCH_LENGTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string ErrorString(Error e);
|
||||||
|
|
||||||
class Result
|
class Result
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user