lnwire: add specification onion errors

In this commit onion routing error from BOLT#4 have been added, the
initial error construction have been splitted on two parts: The first
part which contains the actual data will reside inside the lnwire
package because it contains all necessary function to decode/encode
the data. The second part obfuscation and hmac checking will resides
inside the lighting-onion package because it requires the key
generation.
This commit is contained in:
Andrey Samokhvalov authored and Olaoluwa Osuntokun committed 2017-07-14 19:08:04 -07:00
1 parent d43a660cb1
commit 98956bc2fe
4 files changed
+1086 -91

No files matched your search

+11 -2
View File
@@ -108,12 +108,21 @@ func (u *UnknownMessage) Error() string {
u.messageType)
}
// Serializable is an interface which defines a lightning wire serializable
// object.
type Serializable interface {
// Decode reads the bytes stream and converts it to the object.
Decode(io.Reader, uint32) error
// Encode converts object to the bytes stream and write it in th writer.
Encode(io.Writer, uint32) error
}
// Message is an interface that defines a lightning wire protocol message. The
// interface is general in order to allow implementing types full control over
// the representation of its data.
type Message interface {
Decode(io.Reader, uint32) error
Encode(io.Writer, uint32) error
Serializable
MsgType() MessageType
MaxPayloadLength(uint32) uint32
}