lnrpc+lncli: add TerminateSession command

This commit is contained in:
Elle Mouton committed 2024-02-20 14:44:38 +02:00
1 parent 24702ede14
commit 5d16491c13
9 files changed
+657 -216

No files matched your search

+31
View File
@@ -48,6 +48,10 @@ var (
Entity: "offchain",
Action: "write",
}},
"/wtclientrpc.WatchtowerClient/TerminateSession": {{
Entity: "offchain",
Action: "write",
}},
"/wtclientrpc.WatchtowerClient/ListTowers": {{
Entity: "offchain",
Action: "read",
@@ -281,6 +285,33 @@ func (c *WatchtowerClient) DeactivateTower(_ context.Context,
}, nil
}
// TerminateSession terminates the given session and marks it as terminal so
// that it is never used again.
func (c *WatchtowerClient) TerminateSession(_ context.Context,
req *TerminateSessionRequest) (*TerminateSessionResponse, error) {
if err := c.isActive(); err != nil {
return nil, err
}
pubKey, err := btcec.ParsePubKey(req.SessionId)
if err != nil {
return nil, err
}
sessionID := wtdb.NewSessionIDFromPubKey(pubKey)
err = c.cfg.ClientMgr.TerminateSession(sessionID)
if err != nil {
return nil, err
}
return &TerminateSessionResponse{
Status: fmt.Sprintf("Successful termination of session: %s",
sessionID),
}, nil
}
// ListTowers returns the list of watchtowers registered with the client.
func (c *WatchtowerClient) ListTowers(ctx context.Context,
req *ListTowersRequest) (*ListTowersResponse, error) {