From 3e3e78da98f44d834574851ca65b196d15cf915c Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 3 Dec 2024 09:53:11 +0100 Subject: [PATCH] rfq: fix potential nil pointer panic Because we don't return if the error returned from the price oracle is non-nil, the asset rate might be nil in case we couldn't talk to the oracle. So we need to use fn.MaybeSome() instead of fn.Some() with a dereference. --- rfq/negotiator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rfq/negotiator.go b/rfq/negotiator.go index b5cd86e4d..2dcb97542 100644 --- a/rfq/negotiator.go +++ b/rfq/negotiator.go @@ -194,7 +194,9 @@ func (n *Negotiator) HandleOutgoingBuyOrder(buyOrder BuyOrder) error { "request: %v", err) } - assetRateHint = fn.Some[rfqmsg.AssetRate](*assetRate) + assetRateHint = fn.MaybeSome[rfqmsg.AssetRate]( + assetRate, + ) } // Construct a new buy request to send to the peer.