1 package btcwire
2 3 import "errors"
4 5 // Sentinel errors returned by this package. Every returned error wraps one of
6 // these (or io.ErrUnexpectedEOF for truncated input) together with context
7 // describing what was being decoded, so callers should match them with
8 // errors.Is rather than comparing strings.
9 var (
10 // ErrBadMagic is returned when a frame header carries a network magic
11 // other than the one the caller expects.
12 ErrBadMagic = errors.New("btcwire: unexpected network magic")
13 14 // ErrBadChecksum is returned when the checksum in a frame header does not
15 // match the checksum of the payload that followed it.
16 ErrBadChecksum = errors.New("btcwire: payload checksum mismatch")
17 18 // ErrPayloadTooLarge is returned when a payload exceeds MaxPayload, both
19 // when encoding one and when a frame header declares one.
20 ErrPayloadTooLarge = errors.New("btcwire: payload exceeds maximum size")
21 22 // ErrInvalidCommand is returned when a command is empty, longer than 12
23 // bytes, or contains characters that are not printable ASCII.
24 ErrInvalidCommand = errors.New("btcwire: invalid command")
25 26 // ErrInvalidPayload is returned when a payload is malformed: a message
27 // that must be empty is not, a fixed-size message has the wrong size, a
28 // headers entry declares transactions, and so on.
29 ErrInvalidPayload = errors.New("btcwire: invalid payload")
30 31 // ErrInvalidLength is returned when a length or limit is negative or
32 // otherwise unusable.
33 ErrInvalidLength = errors.New("btcwire: invalid length")
34 35 // ErrVarBytesTooLarge is returned when a variable length byte string is
36 // longer than the caller supplied limit.
37 ErrVarBytesTooLarge = errors.New("btcwire: variable length field exceeds limit")
38 39 // ErrNonCanonicalCompactSize is returned when a compact size integer is
40 // not minimally encoded.
41 ErrNonCanonicalCompactSize = errors.New("btcwire: non-canonical compact size")
42 43 // ErrTooManyItems is returned when a vector in a message declares more
44 // elements than the protocol allows for that message.
45 ErrTooManyItems = errors.New("btcwire: item count exceeds limit")
46 47 // ErrInvalidAddress is returned when an IP address string cannot be
48 // parsed.
49 ErrInvalidAddress = errors.New("btcwire: invalid IP address")
50 51 // ErrTargetNegative is returned for a compact target whose sign bit is
52 // set.
53 ErrTargetNegative = errors.New("btcwire: negative target")
54 55 // ErrTargetOverflow is returned for a compact target that does not fit in
56 // 256 bits.
57 ErrTargetOverflow = errors.New("btcwire: target overflows 256 bits")
58 )
59