Skip to content

Commit f540e9c

Browse files
committed
paymentsdb: add helper method to set session key
This is only used for testing because we have now a unique contraint on the session key and need to swap it in tests for the sql backend. pick f17baec94 paymentsdb: fix linter
1 parent 335a9b3 commit f540e9c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

payments/db/payment.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ func (h *HTLCAttemptInfo) SessionKey() *btcec.PrivateKey {
175175
return h.cachedSessionKey
176176
}
177177

178+
// setSessionKey sets the session key for the htlc attempt.
179+
//
180+
// NOTE: Only used for testing.
181+
//
182+
//nolint:unused
183+
func (h *HTLCAttemptInfo) setSessionKey(sessionKey *btcec.PrivateKey) {
184+
h.cachedSessionKey = sessionKey
185+
186+
// Also set the session key as a raw bytes.
187+
var scratch [btcec.PrivKeyBytesLen]byte
188+
copy(scratch[:], sessionKey.Serialize())
189+
h.sessionKey = scratch
190+
}
191+
178192
// OnionBlob returns the onion blob created from the sphinx construction.
179193
func (h *HTLCAttemptInfo) OnionBlob() ([lnwire.OnionPacketSize]byte, error) {
180194
var zeroBytes [lnwire.OnionPacketSize]byte

0 commit comments

Comments
 (0)