mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-21 22:11:41 +01:00
watchtower/wtdb/session_id: adds SessoinID, client pubkey
This commit is contained in:
parent
bc86ccf212
commit
e825a756f4
1 changed files with 26 additions and 0 deletions
26
watchtower/wtdb/session_id.go
Normal file
26
watchtower/wtdb/session_id.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package wtdb
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
)
|
||||
|
||||
// SessionIDSize is 33-bytes; it is a serialized, compressed public key.
|
||||
const SessionIDSize = 33
|
||||
|
||||
// SessionID is created from the remote public key of a client, and serves as a
|
||||
// unique identifier and authentication for sending state updates.
|
||||
type SessionID [SessionIDSize]byte
|
||||
|
||||
// NewSessionIDFromPubKey creates a new SessionID from a public key.
|
||||
func NewSessionIDFromPubKey(pubKey *btcec.PublicKey) SessionID {
|
||||
var sid SessionID
|
||||
copy(sid[:], pubKey.SerializeCompressed())
|
||||
return sid
|
||||
}
|
||||
|
||||
// String returns a hex encoding of the session id.
|
||||
func (s SessionID) String() string {
|
||||
return hex.EncodeToString(s[:])
|
||||
}
|
Loading…
Add table
Reference in a new issue