Skip to content

Commit d12dc03

Browse files
committed
loopd: avoid panic if asset client is not set
1 parent e145963 commit d12dc03

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

loopd/swapclient_server.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,20 @@ func (s *swapClientServer) marshallSwap(ctx context.Context,
418418
outGoingChanSet = loopSwap.OutgoingChanSet
419419

420420
if loopSwap.AssetSwapInfo != nil {
421-
assetName, err := s.assetClient.GetAssetName(
422-
ctx, loopSwap.AssetSwapInfo.AssetId,
421+
var (
422+
// Default the asset name to "N/A" in case we
423+
// can't fetch it due to the asset client not
424+
// being set.
425+
assetName string = "N/A"
426+
err error
423427
)
424-
if err != nil {
425-
return nil, err
428+
if s.assetClient != nil {
429+
assetName, err = s.assetClient.GetAssetName(
430+
ctx, loopSwap.AssetSwapInfo.AssetId,
431+
)
432+
if err != nil {
433+
return nil, err
434+
}
426435
}
427436

428437
assetInfo = &looprpc.AssetLoopOutInfo{

0 commit comments

Comments
 (0)