package btcwire import "errors" // Sentinel errors returned by this package. Every returned error wraps one of // these (or io.ErrUnexpectedEOF for truncated input) together with context // describing what was being decoded, so callers should match them with // errors.Is rather than comparing strings. var ( // ErrBadMagic is returned when a frame header carries a network magic // other than the one the caller expects. ErrBadMagic = errors.New("btcwire: unexpected network magic") // ErrBadChecksum is returned when the checksum in a frame header does not // match the checksum of the payload that followed it. ErrBadChecksum = errors.New("btcwire: payload checksum mismatch") // ErrPayloadTooLarge is returned when a payload exceeds MaxPayload, both // when encoding one and when a frame header declares one. ErrPayloadTooLarge = errors.New("btcwire: payload exceeds maximum size") // ErrInvalidCommand is returned when a command is empty, longer than 12 // bytes, or contains characters that are not printable ASCII. ErrInvalidCommand = errors.New("btcwire: invalid command") // ErrInvalidPayload is returned when a payload is malformed: a message // that must be empty is not, a fixed-size message has the wrong size, a // headers entry declares transactions, and so on. ErrInvalidPayload = errors.New("btcwire: invalid payload") // ErrInvalidLength is returned when a length or limit is negative or // otherwise unusable. ErrInvalidLength = errors.New("btcwire: invalid length") // ErrVarBytesTooLarge is returned when a variable length byte string is // longer than the caller supplied limit. ErrVarBytesTooLarge = errors.New("btcwire: variable length field exceeds limit") // ErrNonCanonicalCompactSize is returned when a compact size integer is // not minimally encoded. ErrNonCanonicalCompactSize = errors.New("btcwire: non-canonical compact size") // ErrTooManyItems is returned when a vector in a message declares more // elements than the protocol allows for that message. ErrTooManyItems = errors.New("btcwire: item count exceeds limit") // ErrInvalidAddress is returned when an IP address string cannot be // parsed. ErrInvalidAddress = errors.New("btcwire: invalid IP address") // ErrTargetNegative is returned for a compact target whose sign bit is // set. ErrTargetNegative = errors.New("btcwire: negative target") // ErrTargetOverflow is returned for a compact target that does not fit in // 256 bits. ErrTargetOverflow = errors.New("btcwire: target overflows 256 bits") )