diff --git a/watchtower/wtserver/server.go b/watchtower/wtserver/server.go index 3e2d0fa1..1218b1f5 100644 --- a/watchtower/wtserver/server.go +++ b/watchtower/wtserver/server.go @@ -13,6 +13,7 @@ import ( "github.com/btcsuite/btcd/connmgr" "github.com/btcsuite/btcutil" "github.com/lightningnetwork/lnd/lnwire" + "github.com/lightningnetwork/lnd/watchtower/blob" "github.com/lightningnetwork/lnd/watchtower/wtdb" "github.com/lightningnetwork/lnd/watchtower/wtpolicy" "github.com/lightningnetwork/lnd/watchtower/wtwire" @@ -370,6 +371,15 @@ func (s *Server) handleCreateSession(peer Peer, id *wtdb.SessionID, rewardAddrBytes := rewardAddress.ScriptAddress() + // Ensure that the requested blob type is supported by our tower. + if !blob.IsSupportedType(req.BlobType) { + log.Debugf("Rejecting CreateSession from %s, unsupported blob "+ + "type %s", id, req.BlobType) + return s.replyCreateSession( + peer, id, wtwire.CreateSessionCodeRejectBlobType, nil, + ) + } + // TODO(conner): create invoice for upfront payment // Assemble the session info using the agreed upon parameters, reward diff --git a/watchtower/wtserver/server_test.go b/watchtower/wtserver/server_test.go index 37ad57f5..bbca6c13 100644 --- a/watchtower/wtserver/server_test.go +++ b/watchtower/wtserver/server_test.go @@ -170,6 +170,23 @@ var createSessionTests = []createSessionTestCase{ Data: []byte(addr.ScriptAddress()), }, }, + { + name: "reject unsupported blob type", + initMsg: wtwire.NewInitMessage( + lnwire.NewRawFeatureVector(), + lnwire.NewRawFeatureVector(), + ), + createMsg: &wtwire.CreateSession{ + BlobType: 0, + MaxUpdates: 1000, + RewardRate: 0, + SweepFeeRate: 1, + }, + expReply: &wtwire.CreateSessionReply{ + Code: wtwire.CreateSessionCodeRejectBlobType, + Data: []byte{}, + }, + }, // TODO(conner): add policy rejection tests }