From aae61ab16e0dcf15181906fb9b8b4a4c8de52464 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 4 Apr 2019 09:19:20 +0200 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: gballet --- accounts/scwallet/hub.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go index f02728d2b..475305101 100644 --- a/accounts/scwallet/hub.go +++ b/accounts/scwallet/hub.go @@ -87,7 +87,7 @@ type Hub struct { func (hub *Hub) readPairings() error { hub.pairings = make(map[string]smartcardPairing) - pairingFile, err := os.Open(hub.datadir + "/smartcards.json") + pairingFile, err := os.Open(filepath.Join(hub.datadir, "smartcards.json")) if err != nil { if os.IsNotExist(err) { return nil @@ -111,7 +111,7 @@ func (hub *Hub) readPairings() error { } func (hub *Hub) writePairings() error { - pairingFile, err := os.OpenFile(hub.datadir+"/smartcards.json", os.O_RDWR|os.O_CREATE, 0755) + pairingFile, err := os.OpenFile(filepath.Join(hub.datadir,"smartcards.json"), os.O_RDWR|os.O_CREATE, 0755) if err != nil { return err } @@ -134,7 +134,10 @@ func (hub *Hub) writePairings() error { } func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing { - pairing, ok := hub.pairings[string(wallet.PublicKey)] + if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok{ + return &pairing + } + return nil if ok { return &pairing }