mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 06:01:48 +02:00
watchtower/multi: switch over to wtpolicy
migrate to using wtpolicy.Policy in wtwire messages and wtserver
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtdb"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtpolicy"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtwire"
|
||||
)
|
||||
|
||||
@@ -246,14 +247,14 @@ func (s *Server) handleClient(peer Peer) {
|
||||
|
||||
log.Infof("Received CreateSession from %s, "+
|
||||
"version=%d nupdates=%d rewardrate=%d "+
|
||||
"sweepfeerate=%d", id, msg.BlobVersion,
|
||||
"sweepfeerate=%d", id, msg.BlobType,
|
||||
msg.MaxUpdates, msg.RewardRate,
|
||||
msg.SweepFeeRate)
|
||||
|
||||
// Attempt to open a new session for this client.
|
||||
err := s.handleCreateSession(peer, &id, msg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to handle CreateSession "+
|
||||
log.Errorf("Unable to handle CreateSession "+
|
||||
"from %s: %v", id, err)
|
||||
}
|
||||
|
||||
@@ -327,7 +328,7 @@ func (s *Server) handleInit(localInit, remoteInit *wtwire.Init) error {
|
||||
// session info is known about the session id. If an existing session is found,
|
||||
// the reward address is returned in case the client lost our reply.
|
||||
func (s *Server) handleCreateSession(peer Peer, id *wtdb.SessionID,
|
||||
init *wtwire.CreateSession) error {
|
||||
req *wtwire.CreateSession) error {
|
||||
|
||||
// TODO(conner): validate accept against policy
|
||||
|
||||
@@ -375,11 +376,13 @@ func (s *Server) handleCreateSession(peer Peer, id *wtdb.SessionID,
|
||||
// address, and session id.
|
||||
info := wtdb.SessionInfo{
|
||||
ID: *id,
|
||||
Version: init.BlobVersion,
|
||||
MaxUpdates: init.MaxUpdates,
|
||||
RewardRate: init.RewardRate,
|
||||
SweepFeeRate: init.SweepFeeRate,
|
||||
RewardAddress: rewardAddrBytes,
|
||||
Policy: wtpolicy.Policy{
|
||||
BlobType: req.BlobType,
|
||||
MaxUpdates: req.MaxUpdates,
|
||||
RewardRate: req.RewardRate,
|
||||
SweepFeeRate: req.SweepFeeRate,
|
||||
},
|
||||
}
|
||||
|
||||
// Insert the session info into the watchtower's database. If
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"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/wtserver"
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtwire"
|
||||
@@ -155,7 +156,7 @@ var createSessionTests = []createSessionTestCase{
|
||||
lnwire.NewRawFeatureVector(),
|
||||
),
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 1000,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -258,7 +259,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 3,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -287,7 +288,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 4,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -310,7 +311,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 4,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -337,7 +338,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 4,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -364,7 +365,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 4,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -393,7 +394,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 4,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -421,7 +422,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 3,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
@@ -450,7 +451,7 @@ var stateUpdateTests = []stateUpdateTestCase{
|
||||
GlobalFeatures: lnwire.NewRawFeatureVector(),
|
||||
}},
|
||||
createMsg: &wtwire.CreateSession{
|
||||
BlobVersion: 0,
|
||||
BlobType: blob.TypeDefault,
|
||||
MaxUpdates: 3,
|
||||
RewardRate: 0,
|
||||
SweepFeeRate: 1,
|
||||
|
Reference in New Issue
Block a user