From b0525cf478a9226d4ac59b9f525dc3d5d07d441c Mon Sep 17 00:00:00 2001 From: Andrey Samokhvalov Date: Sat, 15 Oct 2016 16:19:11 +0300 Subject: [PATCH] wire: add PendingID in ErrorGeneric --- lnwire/error_generic.go | 10 ++++++++++ lnwire/error_generic_test.go | 1 + 2 files changed, 11 insertions(+) diff --git a/lnwire/error_generic.go b/lnwire/error_generic.go index 1a670e24..c5ff2f0d 100644 --- a/lnwire/error_generic.go +++ b/lnwire/error_generic.go @@ -25,6 +25,13 @@ type ErrorGeneric struct { // nature of the exact error. The maximum allowed length of this // message is 8192 bytes. Problem string + + // PendingChannelID allows peers communicate errors in the context of a + // particular pending channel. With this field, once a peer reads an + // ErrorGeneric message with the PendingChannelID field set, then they + // can forward the error to the fundingManager who can handle it + // properly. + PendingChannelID uint64 } // NewErrorGeneric creates a new ErrorGeneric message. @@ -47,6 +54,7 @@ func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error { &c.ChannelPoint, &c.ErrorID, &c.Problem, + &c.PendingChannelID, ) if err != nil { return err @@ -64,6 +72,7 @@ func (c *ErrorGeneric) Encode(w io.Writer, pver uint32) error { c.ChannelPoint, c.ErrorID, c.Problem, + c.PendingChannelID, ) if err != nil { return err @@ -110,5 +119,6 @@ func (c *ErrorGeneric) String() string { fmt.Sprintf("ChannelPoint:\t%d\n", c.ChannelPoint) + fmt.Sprintf("ErrorID:\t%d\n", c.ErrorID) + fmt.Sprintf("Problem:\t%s\n", c.Problem) + + fmt.Sprintf("PendingChannelID:\t%s\n", c.PendingChannelID) + fmt.Sprintf("--- End ErrorGeneric ---\n") } diff --git a/lnwire/error_generic_test.go b/lnwire/error_generic_test.go index a07e8a60..37519785 100644 --- a/lnwire/error_generic_test.go +++ b/lnwire/error_generic_test.go @@ -11,6 +11,7 @@ func TestErrorGenericEncodeDecode(t *testing.T) { ChannelPoint: outpoint1, ErrorID: 99, Problem: "Hello world!", + PendingChannelID: 1, } // Next encode the EG message into an empty bytes buffer.