Skip to content

Commit

Permalink
fix linter ref fibercrypto#165
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Denis committed Mar 3, 2020
1 parent 6484cf9 commit 0407e45
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/cli/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ func TestRecovery(t *testing.T) {
var stdInDone = false

wg := sync.WaitGroup{}
wg.Add(2)
go func() {
wg.Add(1)
defer wg.Done()
scanner := bufio.NewScanner(stdoutPipe)

Expand All @@ -558,7 +558,6 @@ func TestRecovery(t *testing.T) {
}()

go func() {
wg.Add(1)
defer wg.Done()
scanner := bufio.NewScanner(stderrPipe)
scanner.Split(bufio.ScanWords)
Expand Down
2 changes: 1 addition & 1 deletion src/integration/proxy/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (sq *Sequencer) handleInputReaderResponse(err error) error {
return err
}

func (sq *Sequencer) handleInputReaderCanceled(err error) error {
func (sq *Sequencer) handleInputReaderCanceled(_ error) error {
msg, err := sq.dev.Cancel()
if err != nil {
sq.log.WithError(err).Errorln("unable to cancel command")
Expand Down
2 changes: 1 addition & 1 deletion src/skywallet/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func NewDriver(deviceType DeviceType, emulatorAddress ...string) (*Driver, error
if len(emulatorAddress) == 0 {
emulatorAddress = []string{"127.0.0.1"}
} else if len(emulatorAddress) > 1 {
return nil, ErrInvalidArgCountForEmulatorIpAddress
return nil, ErrInvalidArgCountForEmulatorIPAddress
}
udpBus, err := usb.InitUDP([]int{EmulatorPort}, emulatorAddress[0])
if err != nil {
Expand Down
33 changes: 27 additions & 6 deletions src/skywallet/skywallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ var (
ErrDeviceTypeEmulator = errors.New("device type cannot be emulator")
// ErrInvalidWordCount is returned if word count is not valid mnemonic word length
ErrInvalidWordCount = errors.New("word count must be 12 or 24")
// ErrInvalidArgCountForEmulatorIpAddress emulator ip address is the only one expected argument for emulatorAddress
ErrInvalidArgCountForEmulatorIpAddress = errors.New("emulator ip address is the only one expected argument for emulatorAddress")
// ErrInvalidArgCountForEmulatorIPAddress emulator ip address is the only one expected argument for emulatorAddress
ErrInvalidArgCountForEmulatorIPAddress = errors.New("emulator ip address is the only one expected argument for emulatorAddress")
// ErrNoDeviceConnected is returned if no device is connected to the system
ErrNoDeviceConnected = errors.New("no device connected")
// ErrInvalidWalletType a valid wallet type should be specified
ErrInvalidWalletType = errors.New("invalid wallet type, options are: " + WalletTypeDeterministic + " or " + WalletTypeBip44)
// ErrUserCancelledWithDeviceButton the requested operation has been cancelled from the device input button
ErrUserCancelledWithDeviceButton = errors.New("the requested operation has been cancelled from the device input button")
// ErrUserCancelledFromInputReader the requested operation has been cancelled from the device input button
ErrUserCancelledFromInputReader = errors.New("the requested operation has been cancelled from the user interaction")
// ErrUserCancelledWithDeviceButton the requested operation has been canceled from the device input button
ErrUserCancelledWithDeviceButton = errors.New("the requested operation has been canceled from the device input button")
// ErrUserCancelledFromInputReader the requested operation has been canceled from the device input button
ErrUserCancelledFromInputReader = errors.New("the requested operation has been canceled from the user interaction")
)

const (
Expand All @@ -70,33 +70,54 @@ const (
firstHardenedChild = uint32(0x80000000)
)

// InputRequestKind specify the input required for the reader
type InputRequestKind uint32
const (
// RequestKindPinMatrix require an input reader for a matrix
RequestKindPinMatrix InputRequestKind = iota
// RequestKindPassphrase require an input reader for a pass phrase
RequestKindPassphrase
// RequestKindWord require an input reader for a word
RequestKindWord
// RequestInformUserOnlyOk no special input, just accept
RequestInformUserOnlyOk
// RequestInformUserOnlyCancel just cancel if required
RequestInformUserOnlyCancel
// RequestInformUserOkAndCancel use ok or cancel inpt reader as required
RequestInformUserOkAndCancel
)

//go:generate mockery -name Devicer -case underscore -inpkg -testonly

// Devicer provides api for the hw wallet functions
type Devicer interface {
// AddressGen generate addresses
AddressGen(addressN, startIndex uint32, confirmAddress bool, walletType string) (wire.Message, error)
// ApplySettings to the device
ApplySettings(usePassphrase *bool, label string, language string) (wire.Message, error)
// Backup create a seed backup
Backup() (wire.Message, error)
// Cancel cancel current operation
Cancel() (wire.Message, error)
// CheckMessageSignature check if a message signature is valid
CheckMessageSignature(message, signature, address string) (wire.Message, error)
// ChangePin change device PIN
ChangePin(removePin *bool) (wire.Message, error)
// Connected check if the is a device connected
Connected() bool
// Available check if the device is reachable
Available() bool
// EraseFirmware erase device firmware (bootloader mode).
EraseFirmware(length uint32) (wire.Message, error)
// UploadFirmware upload a new firmware (bootloader mode).
UploadFirmware(payload []byte, hash [32]byte) (wire.Message, error)
// GetFeatures return the device features
GetFeatures() (wire.Message, error)
// GenerateMnemonic generate a mnemonic
GenerateMnemonic(wordCount uint32, usePassphrase bool) (wire.Message, error)
// Recovery a device mnemonic
Recovery(wordCount uint32, usePassphrase *bool, dryRun bool) (wire.Message, error)
// SetMnemonic sets a specific mnemonic
SetMnemonic(mnemonic string) (wire.Message, error)
TransactionSign(inputs []*messages.SkycoinTransactionInput, outputs []*messages.SkycoinTransactionOutput, walletType string) (wire.Message, error)
SignMessage(addressN, addressIndex int, message string, walletType string) (wire.Message, error)
Expand Down

0 comments on commit 0407e45

Please sign in to comment.