Skip to content

Commit

Permalink
Fixing "build constraints exclude all Go files"
Browse files Browse the repository at this point in the history
  • Loading branch information
xaionaro committed Jul 5, 2018
1 parent 1d241df commit 2873ad6
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
4 changes: 3 additions & 1 deletion find_nonsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ package cryptoWallet

import (
"log"

"github.com/xaionaro-go/cryptoWallet/internal/errors"
)

func Find(filter Filter) []Wallet {
log.Panic("cryptowallets are not supported on this platform :(")
log.Panic(errors.ErrNotSupportedPlatform)
return nil
}
4 changes: 4 additions & 0 deletions internal/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ var (
// ErrNotInitialized is returned when trying to do an action requires
// an initialized device on a not initialized device
ErrNotInitialized = fmt.Errorf("The wallet device is not initialized.")

// ErrNotSupportedPlatform is returned/paniced when trying use this library
// on an unsupported platform
ErrNotSupportedPlatform = fmt.Errorf(`"cryptoWallet" is not supported on this platform :(`)
)
5 changes: 5 additions & 0 deletions internal/wallets/satoshilabs/trezor/trezor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// +build linux,cgo darwin,!ios,cgo windows,cgo

// The building requirements above a copied from
// github.com/trezor/usbhid/libusb.go (commit: 519ec1000beb862bbe9b16b99d782ab77787ea18)

package trezorBase

import (
Expand Down
51 changes: 51 additions & 0 deletions internal/wallets/satoshilabs/trezor/trezor_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// +build !cgo iso !linux,!darwin,!windows

package trezorBase

import (
"log"

"github.com/conejoninja/tesoro/pb/messages"
"github.com/xaionaro-go/cryptoWallet/internal/errors"
"github.com/xaionaro-go/cryptoWallet/internal/wallets/satoshilabs"
"github.com/zserge/hid"
)

// TrezorBase -- see trezor.go
type TrezorBase struct {
satoshilabsWallet.Base
}

// SetHIDDevice -- see trezor.go
func (trezor *TrezorBase) SetHIDDevice(device hid.Device) {
log.Panic(errors.ErrNotSupportedPlatform)
}
// Reset -- see trezor.go
func (trezor *TrezorBase) Reset() error {
return errors.ErrNotSupportedPlatform
}
// Ping -- see trezor.go
func (trezor *TrezorBase) Ping() error {
return errors.ErrNotSupportedPlatform
}
// Reconnect -- see trezor.go
func (trezor *TrezorBase) Reconnect() error {
return errors.ErrNotSupportedPlatform
}
// CheckConnection -- see trezor.go
func (trezor *TrezorBase) CheckConnection() error {
return errors.ErrNotSupportedPlatform
}
// CipherKeyValue -- see trezor.go
func (trezor *TrezorBase) CipherKeyValue(path string, isToEncrypt bool, keyName string, data, iv []byte, askOnEncode, askOnDecode bool) ([]byte, messages.MessageType) {
log.Panic(errors.ErrNotSupportedPlatform)
return nil, messages.MessageType_MessageType_Failure
}
// EncryptKey -- see trezor.go
func (trezor *TrezorBase) EncryptKey(path string, decryptedKey []byte, nonce []byte, trezorKeyname string) ([]byte, error) {
return nil, errors.ErrNotSupportedPlatform
}
// DecryptKey -- see trezor.go
func (trezor *TrezorBase) DecryptKey(path string, encryptedKey []byte, nonce []byte, trezorKeyname string) ([]byte, error) {
return nil, errors.ErrNotSupportedPlatform
}

0 comments on commit 2873ad6

Please sign in to comment.