bech32: add additional field to ErrInvalidChecksum (bech32m version)
In this commit, we add an additional field to the ErrInvalidChecksum, the bech32m version of a checksum. When decoding, we don't now what version they actually _intended_ to use, so we'll opt to include both checksums to aide in debugging and error reporting.
This commit is contained in:
parent
3ecfc35771
commit
14f90e5946
1 changed files with 7 additions and 5 deletions
|
@ -65,15 +65,17 @@ func (e ErrNonCharsetChar) Error() string {
|
|||
}
|
||||
|
||||
// ErrInvalidChecksum is returned when the extracted checksum of the string
|
||||
// is different than what was expected.
|
||||
// is different than what was expected. Both the original version, as well as
|
||||
// the new bech32m checksum may be specified.
|
||||
type ErrInvalidChecksum struct {
|
||||
Expected string
|
||||
Actual string
|
||||
Expected string
|
||||
ExpectedM string
|
||||
Actual string
|
||||
}
|
||||
|
||||
func (e ErrInvalidChecksum) Error() string {
|
||||
return fmt.Sprintf("invalid checksum (expected %v got %v)",
|
||||
e.Expected, e.Actual)
|
||||
return fmt.Sprintf("invalid checksum (expected (bech32=%v, "+
|
||||
"bech32m=%v), got %v)", e.Expected, e.ExpectedM, e.Actual)
|
||||
}
|
||||
|
||||
// ErrInvalidDataByte is returned when a byte outside the range required for
|
||||
|
|
Loading…
Reference in a new issue