From 0db39d4fe617218f8639780a0f0c24b3511f4028 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 20 Jun 2019 16:53:25 -0700 Subject: [PATCH] lnrpc/watchtowerrpc: add WatchtowerBackend configs --- lnrpc/watchtowerrpc/config_active.go | 13 +++++++++++++ lnrpc/watchtowerrpc/config_default.go | 6 ++++++ lnrpc/watchtowerrpc/interface.go | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 lnrpc/watchtowerrpc/config_active.go create mode 100644 lnrpc/watchtowerrpc/config_default.go create mode 100644 lnrpc/watchtowerrpc/interface.go diff --git a/lnrpc/watchtowerrpc/config_active.go b/lnrpc/watchtowerrpc/config_active.go new file mode 100644 index 00000000..985b49bf --- /dev/null +++ b/lnrpc/watchtowerrpc/config_active.go @@ -0,0 +1,13 @@ +// +build watchtowerrpc + +package watchtowerrpc + +// Config is the primary configuration struct for the watchtower RPC server. It +// contains all items required for the RPC server to carry out its duties. The +// fields with struct tags are meant to parsed as normal configuration options, +// while if able to be populated, the latter fields MUST also be specified. +type Config struct { + // Tower is the active watchtower which serves as the primary source for + // information presented via RPC. + Tower WatchtowerBackend +} diff --git a/lnrpc/watchtowerrpc/config_default.go b/lnrpc/watchtowerrpc/config_default.go new file mode 100644 index 00000000..ac40e0bf --- /dev/null +++ b/lnrpc/watchtowerrpc/config_default.go @@ -0,0 +1,6 @@ +// +build !watchtowerrpc + +package watchtowerrpc + +// Config is empty for non-watchtowerrpc builds. +type Config struct{} diff --git a/lnrpc/watchtowerrpc/interface.go b/lnrpc/watchtowerrpc/interface.go new file mode 100644 index 00000000..aafe3e06 --- /dev/null +++ b/lnrpc/watchtowerrpc/interface.go @@ -0,0 +1,23 @@ +package watchtowerrpc + +import ( + "net" + + "github.com/btcsuite/btcd/btcec" +) + +// WatchtowerBackend abstracts access to the watchtower information that is +// served via RPC connections. +type WatchtowerBackend interface { + // PubKey returns the public key for the watchtower used to + // authentication and encrypt traffic with clients. + PubKey() *btcec.PublicKey + + // ListeningAddrs returns the listening addresses where the watchtower + // server can accept client connections. + ListeningAddrs() []net.Addr + + // ExternalIPs returns the addresses where the watchtower can be reached + // by clients externally. + ExternalIPs() []net.Addr +}