From 61be23dc313a680776a49952d76e532d6d772add Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 16 Oct 2017 18:39:06 -0700 Subject: [PATCH] htlcswitch+server: add new field SelfKey to htlcswitch.Config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new field to the switch’s Config, namely the public key of the backing lightning node. This field will soon be used to return more detailed errors messages back to the ChannelRouter itself. --- htlcswitch/switch.go | 10 ++++++++-- server.go | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 8f45d263..12a1353f 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -9,6 +9,7 @@ import ( "crypto/sha256" "github.com/davecgh/go-spew/spew" + "github.com/roasbeef/btcd/btcec" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/lnrpc" @@ -85,8 +86,13 @@ type ChanClose struct { // Config defines the configuration for the service. ALL elements within the // configuration MUST be non-nil for the service to carry out its duties. type Config struct { - // LocalChannelClose kicks-off the workflow to execute a cooperative - // or forced unilateral closure of the channel initiated by a local + // SelfKey is the key of the backing Lightning node. This key is used + // to properly craft failure messages, such that the Layer 3 router can + // properly route around link./vertex failures. + SelfKey *btcec.PublicKey + + // LocalChannelClose kicks-off the workflow to execute a cooperative or + // forced unilateral closure of the channel initiated by a local // subsystem. LocalChannelClose func(pubKey []byte, request *ChanClose) } diff --git a/server.go b/server.go index 4425fb72..14340141 100644 --- a/server.go +++ b/server.go @@ -176,6 +176,7 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl, } s.htlcSwitch = htlcswitch.New(htlcswitch.Config{ + SelfKey: s.identityPriv.PubKey(), LocalChannelClose: func(pubKey []byte, request *htlcswitch.ChanClose) {