remove SelectNotInitialized
This commit is contained in:
parent
d92ae609b7
commit
a2d65ea700
|
@ -16,6 +16,8 @@ var (
|
|||
errAppletNotInstalled = errors.New("applet not installed")
|
||||
errCardNotInitialized = errors.New("card not initialized")
|
||||
errCardAlreadyInitialized = errors.New("card already initialized")
|
||||
|
||||
ErrNotInitialized = errors.New("card not initialized")
|
||||
)
|
||||
|
||||
// Initializer defines a struct with methods to install applets and initialize a card.
|
||||
|
@ -87,11 +89,15 @@ func (i *Initializer) Init() (*lightwallet.Secrets, error) {
|
|||
}
|
||||
|
||||
func (i *Initializer) Pair(pairingPass, pin string) (*lightwallet.PairingInfo, error) {
|
||||
_, err := actions.SelectInitialized(i.c, lightwallet.WalletAID)
|
||||
appInfo, err := actions.Select(i.c, lightwallet.WalletAID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !appInfo.Initialized {
|
||||
return nil, ErrNotInitialized
|
||||
}
|
||||
|
||||
return actions.Pair(i.c, pairingPass, pin)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
|
||||
var (
|
||||
ErrAlreadyInitialized = errors.New("card already initialized")
|
||||
ErrNotInitialized = errors.New("card not initialized")
|
||||
ErrWrongApplicationInfoTemplate = errors.New("wrong application info template")
|
||||
ErrApplicationStatusTemplateNotFound = errors.New("application status template not found")
|
||||
)
|
||||
|
@ -48,34 +47,6 @@ func Select(c globalplatform.Channel, aid []byte) (*lightwallet.ApplicationInfo,
|
|||
return parseApplicationInfo(resp.Data, info)
|
||||
}
|
||||
|
||||
func SelectNotInitialized(c globalplatform.Channel, aid []byte) ([]byte, error) {
|
||||
sel := globalplatform.NewCommandSelect(aid)
|
||||
resp, err := c.Send(sel)
|
||||
if err = checkOKResponse(err, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Data[0] != lightwallet.TagSelectResponsePreInitialized {
|
||||
return nil, ErrAlreadyInitialized
|
||||
}
|
||||
|
||||
return resp.Data[2:], nil
|
||||
}
|
||||
|
||||
func SelectInitialized(c globalplatform.Channel, aid []byte) (*lightwallet.ApplicationInfo, error) {
|
||||
sel := globalplatform.NewCommandSelect(aid)
|
||||
resp, err := c.Send(sel)
|
||||
if err = checkOKResponse(err, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.Data[0] == lightwallet.TagSelectResponsePreInitialized {
|
||||
return nil, ErrNotInitialized
|
||||
}
|
||||
|
||||
return parseApplicationInfo(resp.Data, &lightwallet.ApplicationInfo{})
|
||||
}
|
||||
|
||||
func Init(c globalplatform.Channel, cardPubKey []byte, secrets *lightwallet.Secrets, aid []byte) error {
|
||||
secureChannel, err := lightwallet.NewSecureChannel(c, cardPubKey)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue