lnwire: add cancellation reason to htlc cancel messages
This commit adds a new field to the CancelHTLC message which describes the event that led to an HTLC being cancelled up stream. A new enum has been added which describers the “why” concerning the cancellation of the HTLC. Currently the encoding and back propagation of the errors aren’t properly implemented as defined within the spec. As a result the current error types provide to privacy as the error are in plain-site rather doing being properly encrypted.
This commit is contained in:
3 files changed
+82
-4
No files matched your search
@@ -88,6 +88,12 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
if _, err := w.Write(b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
case CancelReason:
|
||||
var b [2]byte
|
||||
binary.BigEndian.PutUint16(b[:], uint16(e))
|
||||
if _, err := w.Write(b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
case ErrorCode:
|
||||
var b [2]byte
|
||||
binary.BigEndian.PutUint16(b[:], uint16(e))
|
||||
@@ -384,6 +390,12 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
return err
|
||||
}
|
||||
*e = b[0]
|
||||
case *CancelReason:
|
||||
var b [2]byte
|
||||
if _, err := io.ReadFull(r, b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
*e = CancelReason(binary.BigEndian.Uint16(b[:]))
|
||||
case *uint16:
|
||||
var b [2]byte
|
||||
if _, err := io.ReadFull(r, b[:]); err != nil {
|
||||
|
||||
Reference in new issue
Block a user