@Override
  public void showButtonPress(HardwareWalletEvent event) {

    ButtonRequest buttonRequest = (ButtonRequest) event.getMessage().get();

    switch (state) {
      case TREZOR_CREATE_WALLET_REQUEST_CREATE_WALLET:
        switch (buttonRequest.getButtonRequestType()) {
          case OTHER:
            break;
          case FEE_OVER_THRESHOLD:
            break;
          case CONFIRM_OUTPUT:
            break;
          case RESET_DEVICE:
            break;
          case CONFIRM_WORD:
            break;
          case WIPE_DEVICE:
            // Device requires confirmation to wipe device
            state = TREZOR_CREATE_WALLET_CONFIRM_CREATE_WALLET;
            break;
          case PROTECT_CALL:
            break;
          case SIGN_TX:
            break;
          case FIRMWARE_CHECK:
            break;
          case ADDRESS:
            break;
          default:
            throw new IllegalStateException(
                "Unexpected button: " + buttonRequest.getButtonRequestType().name());
        }
        break;
      case TREZOR_CREATE_WALLET_CONFIRM_WORD:
        switch (buttonRequest.getButtonRequestType()) {
          case OTHER:
            break;
          case FEE_OVER_THRESHOLD:
            break;
          case CONFIRM_OUTPUT:
            break;
          case RESET_DEVICE:
            break;
          case CONFIRM_WORD:
            trezorWordCount++;
            if (trezorWordCount > trezorSeedPhraseSize.getSize()) {
              log.debug("Reset word count for confirm phase");
              trezorWordCount = 1;
              trezorChecking = true;
            }
            // Device requires confirmation of word in seed phrase
            // See "operation succeeded" for next state transition
            state = TREZOR_CREATE_WALLET_CONFIRM_WORD;
            trezorConfirmWordPanelView.updateDisplay(trezorWordCount, trezorChecking);
            break;
          case WIPE_DEVICE:
            break;
          case PROTECT_CALL:
            break;
          case SIGN_TX:
            break;
          case FIRMWARE_CHECK:
            break;
          case ADDRESS:
            break;
          default:
            throw new IllegalStateException(
                "Unexpected button: " + buttonRequest.getButtonRequestType().name());
        }
        break;
      default:
        throw new IllegalStateException("Unknown state: " + state.name());
    }
  }
  @Override
  public void showNext() {

    Optional<HardwareWalletService> hardwareWalletService;

    switch (state) {
      case WELCOME_LICENCE:
        state = WELCOME_SELECT_LANGUAGE;
        break;
      case WELCOME_SELECT_LANGUAGE:
        state = WELCOME_ATTACH_HARDWARE_WALLET;
        break;
      case WELCOME_ATTACH_HARDWARE_WALLET:
        hardwareWalletService = CoreServices.getOrCreateHardwareWalletService();
        if (hardwareWalletService.isPresent() && hardwareWalletService.get().isDeviceReady()) {
          // A Trezor is connected
          mode = WelcomeWizardMode.TREZOR;
          if (hardwareWalletService.get().isWalletPresent()) {
            // User may want to create or restore since they have an initialised device
            state = WELCOME_SELECT_WALLET;
          } else {
            // User can only create from an uninitialised device
            state = TREZOR_CREATE_WALLET_PREPARATION;
          }
        } else {
          // Standard mode
          mode = WelcomeWizardMode.STANDARD;
          state = WELCOME_SELECT_WALLET;
        }
        break;
      case WELCOME_SELECT_WALLET:
        hardwareWalletService = CoreServices.getOrCreateHardwareWalletService();
        if (RESTORE_WALLET_SELECT_BACKUP.equals(selectWalletChoice)) {
          if (hardwareWalletService.isPresent()
              && hardwareWalletService.get().isDeviceReady()
              && hardwareWalletService.get().isWalletPresent()) {
            // Initialised hardware wallet is attached
            calculateRestoreMethod();
            break;
          }
        } else {
          // Ensure Trezor is reset if it is attached and initialised
          if (hardwareWalletService.isPresent() && hardwareWalletService.get().isDeviceReady()) {
            hardwareWalletService.get().requestCancel();
            hardwareWalletService.get().getContext().resetToConnected();
          }
          state = selectWalletChoice;
        }
        break;
      case CREATE_WALLET_PREPARATION:
        state = CREATE_WALLET_SELECT_BACKUP_LOCATION;
        break;
      case CREATE_WALLET_SELECT_BACKUP_LOCATION:
        state = CREATE_WALLET_SEED_PHRASE;
        break;
      case CREATE_WALLET_SEED_PHRASE:
        state = CREATE_WALLET_CONFIRM_SEED_PHRASE;
        // Fail safe to ensure that the generator hasn't gone screwy
        Preconditions.checkState(
            SeedPhraseSize.isValid(getCreateWalletSeedPhrase().size()),
            "'actualSeedPhrase' is not a valid length");
        break;
      case CREATE_WALLET_CONFIRM_SEED_PHRASE:
        state = CREATE_WALLET_CREATE_PASSWORD;
        break;
      case CREATE_WALLET_CREATE_PASSWORD:
        state = CREATE_WALLET_REPORT;
        break;
      case CREATE_WALLET_REPORT:
        throw new IllegalStateException("'Next' is not permitted here");
      case TREZOR_CREATE_WALLET_PREPARATION:
        state = TREZOR_CREATE_WALLET_SELECT_BACKUP_LOCATION;
        break;
      case TREZOR_CREATE_WALLET_SELECT_BACKUP_LOCATION:
        state = TREZOR_CREATE_WALLET_ENTER_DETAILS;
        break;
      case TREZOR_CREATE_WALLET_ENTER_DETAILS:
        state = TREZOR_CREATE_WALLET_REQUEST_CREATE_WALLET;
        break;
      case TREZOR_CREATE_WALLET_REQUEST_CREATE_WALLET:
        state = TREZOR_CREATE_WALLET_CONFIRM_CREATE_WALLET;
        break;
      case TREZOR_CREATE_WALLET_CONFIRM_CREATE_WALLET:
        state = TREZOR_CREATE_WALLET_CONFIRM_ENTROPY;
        break;
      case TREZOR_CREATE_WALLET_CONFIRM_ENTROPY:
        state = TREZOR_CREATE_WALLET_ENTER_NEW_PIN;
        break;
      case TREZOR_CREATE_WALLET_ENTER_NEW_PIN:
        state = TREZOR_CREATE_WALLET_CONFIRM_NEW_PIN;
        break;
      case TREZOR_CREATE_WALLET_CONFIRM_NEW_PIN:
        state = TREZOR_CREATE_WALLET_CONFIRM_WORD;
        break;
      case TREZOR_CREATE_WALLET_CONFIRM_WORD:
        state = TREZOR_CREATE_WALLET_REPORT;
        break;
      case TREZOR_CREATE_WALLET_REPORT:
        break;
      case RESTORE_PASSWORD_SEED_PHRASE:
        state = RESTORE_PASSWORD_REPORT;
        break;
      case RESTORE_PASSWORD_REPORT:
        break;
      case RESTORE_WALLET_SEED_PHRASE:
        if (!isLocalZipBackupPresent()) {
          restoreMethod = RESTORE_WALLET_SELECT_BACKUP_LOCATION;
        } else {
          restoreMethod = RESTORE_WALLET_SELECT_BACKUP;
        }
        state = restoreMethod;
        break;
      case RESTORE_WALLET_SELECT_BACKUP_LOCATION:
        if (isCloudBackupPresent()) {
          restoreMethod = RESTORE_WALLET_SELECT_BACKUP;
        } else {
          restoreMethod = RESTORE_WALLET_TIMESTAMP;
        }
        state = restoreMethod;
        break;
      case RESTORE_WALLET_SELECT_BACKUP:
        state = RESTORE_WALLET_REPORT;
        break;
      case RESTORE_WALLET_TIMESTAMP:
        state = RESTORE_WALLET_REPORT;
        break;
      case RESTORE_WALLET_REPORT:
        throw new IllegalStateException("'Next' is not permitted here");
      default:
        throw new IllegalStateException("Unknown state: " + state.name());
    }
  }