Skip to content

Commit 843a941

Browse files
authored
Merge pull request #170 from gz-c/wallet-verify
Verify configured wallet file on startup
2 parents ffa5e8e + 2468504 commit 843a941

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/config/config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/spf13/viper"
1313

1414
"github.com/skycoin/skycoin/src/daemon"
15+
"github.com/skycoin/skycoin/src/wallet"
1516
"github.com/skycoin/teller/src/util/mathutil"
1617
)
1718

@@ -219,7 +220,14 @@ func (c Config) Validate() error {
219220
}
220221

221222
if _, err := os.Stat(c.SkyExchanger.Wallet); os.IsNotExist(err) {
222-
oops("sky_exchanger.wallet file does not exist")
223+
oops(fmt.Sprintf("sky_exchanger.wallet file %s does not exist", c.SkyExchanger.Wallet))
224+
}
225+
226+
w, err := wallet.Load(c.SkyExchanger.Wallet)
227+
if err != nil {
228+
oops(fmt.Sprintf("sky_exchanger.wallet file %s failed to load: %v", c.SkyExchanger.Wallet, err))
229+
} else if err := w.Validate(); err != nil {
230+
oops(fmt.Sprintf("sky_exchanger.wallet file %s is invalid: %v", c.SkyExchanger.Wallet, err))
223231
}
224232
}
225233

0 commit comments

Comments
 (0)