watchtower/wtserver/server: check blob type first

This commit is contained in:
Conner Fromknecht 2019-04-23 20:05:12 -07:00
parent bebe6461a9
commit 999cbbdc54
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

View File

@ -40,6 +40,15 @@ func (s *Server) handleCreateSession(peer Peer, id *wtdb.SessionID,
)
}
// 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,
)
}
// Now that we've established that this session does not exist in the
// database, retrieve the sweep address that will be given to the
// client. This address is to be included by the client when signing
@ -63,15 +72,6 @@ func (s *Server) handleCreateSession(peer Peer, id *wtdb.SessionID,
)
}
// 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