channeldb: read raw htlc attempt session key
This commit is contained in:
5 files changed
+52
-23
No files matched your search
+12
-5
@@ -21,8 +21,10 @@ type HTLCAttemptInfo struct {
|
||||
// AttemptID is the unique ID used for this attempt.
|
||||
AttemptID uint64
|
||||
|
||||
// sessionKey is the ephemeral key used for this attempt.
|
||||
sessionKey *btcec.PrivateKey
|
||||
// sessionKey is the raw bytes ephemeral key used for this attempt.
|
||||
// These bytes are lazily read off disk to save ourselves the expensive
|
||||
// EC operations used by btcec.PrivKeyFromBytes.
|
||||
sessionKey [btcec.PrivKeyBytesLen]byte
|
||||
|
||||
// Route is the route attempted to send the HTLC.
|
||||
Route route.Route
|
||||
@@ -43,18 +45,23 @@ func NewHtlcAttemptInfo(attemptID uint64, sessionKey *btcec.PrivateKey,
|
||||
route route.Route, attemptTime time.Time,
|
||||
hash *lntypes.Hash) *HTLCAttemptInfo {
|
||||
|
||||
var scratch [btcec.PrivKeyBytesLen]byte
|
||||
copy(scratch[:], sessionKey.Serialize())
|
||||
|
||||
return &HTLCAttemptInfo{
|
||||
AttemptID: attemptID,
|
||||
sessionKey: sessionKey,
|
||||
sessionKey: scratch,
|
||||
Route: route,
|
||||
AttemptTime: attemptTime,
|
||||
Hash: hash,
|
||||
}
|
||||
}
|
||||
|
||||
// SessionKey returns the ephemeral key used for a htlc attempt.
|
||||
// SessionKey returns the ephemeral key used for a htlc attempt. This function
|
||||
// performs expensive ec-ops to obtain the session key.
|
||||
func (h *HTLCAttemptInfo) SessionKey() *btcec.PrivateKey {
|
||||
return h.sessionKey
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), h.sessionKey[:])
|
||||
return priv
|
||||
}
|
||||
|
||||
// HTLCAttempt contains information about a specific HTLC attempt for a given
|
||||
|
||||
Reference in new issue
Block a user