From 8be3d6ebcbed60a8a5b5332b12d214960fcd603d Mon Sep 17 00:00:00 2001 From: Andrea Franz Date: Tue, 6 Nov 2018 13:04:00 +0100 Subject: [PATCH] add more error messages for init command --- cmd/applet-installer/main.go | 1 + lightwallet/actionsets/installer.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/applet-installer/main.go b/cmd/applet-installer/main.go index 392aebf..36f53c3 100644 --- a/cmd/applet-installer/main.go +++ b/cmd/applet-installer/main.go @@ -162,6 +162,7 @@ func commandInstall(i *actionsets.Installer) error { } defer f.Close() + fmt.Printf("installation can take a while...\n") err = i.Install(f, *flagOverwrite) if err != nil { fail("installation error", "error", err) diff --git a/lightwallet/actionsets/installer.go b/lightwallet/actionsets/installer.go index 4fa80dc..2cc2909 100644 --- a/lightwallet/actionsets/installer.go +++ b/lightwallet/actionsets/installer.go @@ -70,12 +70,20 @@ func (i *Installer) Init() (*lightwallet.Secrets, error) { return nil, err } - cardPubKey, err := actions.SelectNotInitialized(i.c, walletAID) + info, err := actions.Select(i.c, walletAID) if err != nil { return nil, err } - err = actions.Init(i.c, cardPubKey, secrets, walletAID) + if !info.Installed { + return nil, fmt.Errorf("applet not installed") + } + + if info.Initialized { + return nil, fmt.Errorf("card already initialized") + } + + err = actions.Init(i.c, info.PublicKey, secrets, walletAID) if err != nil { return nil, err }