diff --git a/watchtower/wtdb/client_chan_summary.go b/watchtower/wtdb/client_chan_summary.go new file mode 100644 index 000000000..d4b3c3c38 --- /dev/null +++ b/watchtower/wtdb/client_chan_summary.go @@ -0,0 +1,32 @@ +package wtdb + +import ( + "io" + + "github.com/lightningnetwork/lnd/lnwire" +) + +// ChannelSummaries is a map for a given channel id to it's ClientChanSummary. +type ChannelSummaries map[lnwire.ChannelID]ClientChanSummary + +// ClientChanSummary tracks channel-specific information. A new +// ClientChanSummary is inserted in the database the first time the client +// encounters a particular channel. +type ClientChanSummary struct { + // SweepPkScript is the pkscript to which all justice transactions will + // deposit recovered funds for this particular channel. + SweepPkScript []byte + + // TODO(conner): later extend with info about initial commit height, + // ineligible states, etc. +} + +// Encode writes the ClientChanSummary to the passed io.Writer. +func (s *ClientChanSummary) Encode(w io.Writer) error { + return WriteElement(w, s.SweepPkScript) +} + +// Decode reads a ClientChanSummary form the passed io.Reader. +func (s *ClientChanSummary) Decode(r io.Reader) error { + return ReadElement(r, &s.SweepPkScript) +} diff --git a/watchtower/wtdb/codec_test.go b/watchtower/wtdb/codec_test.go index 21e11c6fd..69c7b0594 100644 --- a/watchtower/wtdb/codec_test.go +++ b/watchtower/wtdb/codec_test.go @@ -153,6 +153,8 @@ func TestCodec(tt *testing.T) { obj2 = &wtdb.BackupID{} case *wtdb.Tower: obj2 = &wtdb.Tower{} + case *wtdb.ClientChanSummary: + obj2 = &wtdb.ClientChanSummary{} default: t.Fatalf("unknown type: %T", obj) return false @@ -238,6 +240,12 @@ func TestCodec(tt *testing.T) { return mainScenario(&obj) }, }, + { + name: "ClientChanSummary", + scenario: func(obj wtdb.ClientChanSummary) bool { + return mainScenario(&obj) + }, + }, } for _, test := range tests {