From f540e9c8ec63a1d4873e37b3616fe921dc6a9112 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 26 Aug 2025 12:24:28 +0200 Subject: [PATCH] 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 --- payments/db/payment.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/payments/db/payment.go b/payments/db/payment.go index b863cea5e..f6d998344 100644 --- a/payments/db/payment.go +++ b/payments/db/payment.go @@ -175,6 +175,20 @@ func (h *HTLCAttemptInfo) SessionKey() *btcec.PrivateKey { return h.cachedSessionKey } +// setSessionKey sets the session key for the htlc attempt. +// +// NOTE: Only used for testing. +// +//nolint:unused +func (h *HTLCAttemptInfo) setSessionKey(sessionKey *btcec.PrivateKey) { + h.cachedSessionKey = sessionKey + + // Also set the session key as a raw bytes. + var scratch [btcec.PrivKeyBytesLen]byte + copy(scratch[:], sessionKey.Serialize()) + h.sessionKey = scratch +} + // OnionBlob returns the onion blob created from the sphinx construction. func (h *HTLCAttemptInfo) OnionBlob() ([lnwire.OnionPacketSize]byte, error) { var zeroBytes [lnwire.OnionPacketSize]byte