lnd/watchtower/wtdb/session_id.go
Oliver Gugger 7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00

27 lines
698 B
Go

package wtdb
import (
"encoding/hex"
"github.com/btcsuite/btcd/btcec/v2"
)
// 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[:])
}