watchtower/wtserver: reject unknown blob types
This commit is contained in:
parent
4f3655ba93
commit
ca3e06b785
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user