diff --git a/lightwallet/commands.go b/lightwallet/commands.go index 88dcb97..a2c8392 100644 --- a/lightwallet/commands.go +++ b/lightwallet/commands.go @@ -7,6 +7,8 @@ import ( const ( InsInit = uint8(0xFE) + + tagSelectResponsePreInitialized = uint8(0x80) ) func NewCommandInit(data []byte) *apdu.Command { diff --git a/lightwallet/installer.go b/lightwallet/installer.go index 857d376..173c4bb 100644 --- a/lightwallet/installer.go +++ b/lightwallet/installer.go @@ -74,6 +74,11 @@ func (i *Installer) Init() (*Secrets, error) { return nil, err } + if resp.Data[0] != tagSelectResponsePreInitialized { + err := fmt.Errorf("card already initialized (%x).", resp.Data[0]) + return nil, err + } + cardKeyData := resp.Data[2:] secureChannel, err := NewSecureChannel(i.c, cardKeyData) if err != nil { @@ -91,8 +96,6 @@ func (i *Installer) Init() (*Secrets, error) { return nil, err } - fmt.Printf("RESP: %+v\n", resp) - return secrets, nil }