@Override
    public void parse() {
      if (input.startsWith("bitcoin:")) {
        try {
          final BitcoinURI bitcoinUri = new BitcoinURI(null, input);
          final Address address = bitcoinUri.getAddress();
          final String addressLabel = bitcoinUri.getLabel();
          final BigInteger amount = bitcoinUri.getAmount();
          final String bluetoothMac =
              (String) bitcoinUri.getParameterByName(Bluetooth.MAC_URI_PARAM);

          bitcoinRequest(address, addressLabel, amount, bluetoothMac);
        } catch (final BitcoinURIParseException x) {
          error(R.string.input_parser_invalid_bitcoin_uri, input);
        }
      } else if (PATTERN_BITCOIN_ADDRESS.matcher(input).matches()) {
        try {
          final Address address = new Address(Constants.NETWORK_PARAMETERS, input);

          bitcoinRequest(address, null, null, null);
        } catch (final AddressFormatException x) {
          error(R.string.input_parser_invalid_address);
        }
      } else if (PATTERN_PRIVATE_KEY.matcher(input).matches()) {
        try {
          final ECKey key = new DumpedPrivateKey(Constants.NETWORK_PARAMETERS, input).getKey();
          final Address address = new Address(Constants.NETWORK_PARAMETERS, key.getPubKeyHash());

          bitcoinRequest(address, null, null, null);
        } catch (final AddressFormatException x) {
          error(R.string.input_parser_invalid_address);
        }
      } else if (PATTERN_TRANSACTION.matcher(input).matches()) {
        try {
          final Transaction tx =
              new Transaction(Constants.NETWORK_PARAMETERS, Qr.decodeBinary(input));

          directTransaction(tx);
        } catch (final IOException x) {
          error(R.string.input_parser_invalid_transaction, x.getMessage());
        } catch (final ProtocolException x) {
          error(R.string.input_parser_invalid_transaction, x.getMessage());
        }
      } else {
        cannotClassify(input);
      }
    }
    @Override
    public void parse() {
      if (input.startsWith("MINTCOIN:-")) {
        try {
          final byte[] serializedPaymentRequest = Qr.decodeBinary(input.substring(9));

          parseAndHandlePaymentRequest(serializedPaymentRequest);
        } catch (final IOException x) {
          log.info("i/o error while fetching payment request", x);

          error(R.string.input_parser_io_error, x.getMessage());
        } catch (final PkiVerificationException x) {
          log.info("got unverifyable payment request", x);

          error(R.string.input_parser_unverifyable_paymentrequest, x.getMessage());
        } catch (final PaymentRequestException x) {
          log.info("got invalid payment request", x);

          error(R.string.input_parser_invalid_paymentrequest, x.getMessage());
        }
      }
      if (input.startsWith("mintcoin:")) {
        try {
          final BitcoinURI bitcoinUri = new BitcoinURI(null, input);

          final Address address = bitcoinUri.getAddress();
          if (address == null) throw new BitcoinURIParseException("missing address");

          if (address.getParameters().equals(Constants.NETWORK_PARAMETERS))
            handlePaymentIntent(PaymentIntent.fromBitcoinUri(bitcoinUri));
          else error(R.string.input_parser_invalid_address, input);
        } catch (final BitcoinURIParseException x) {
          log.info("got invalid mintcoin uri: '" + input + "'", x);

          error(R.string.input_parser_invalid_bitcoin_uri, input);
        }
      } else if (PATTERN_BITCOIN_ADDRESS.matcher(input).matches()) {
        try {
          final Address address = new Address(Constants.NETWORK_PARAMETERS, input);

          handlePaymentIntent(PaymentIntent.fromAddress(address, null));
        } catch (final AddressFormatException x) {
          log.info("got invalid address", x);

          error(R.string.input_parser_invalid_address);
        }
      } else if (PATTERN_PRIVATE_KEY.matcher(input).matches()) {
        try {
          final ECKey key = new DumpedPrivateKey(Constants.NETWORK_PARAMETERS, input).getKey();
          final Address address = new Address(Constants.NETWORK_PARAMETERS, key.getPubKeyHash());

          handlePaymentIntent(PaymentIntent.fromAddress(address, null));
        } catch (final AddressFormatException x) {
          log.info("got invalid address", x);

          error(R.string.input_parser_invalid_address);
        }
      } else if (PATTERN_TRANSACTION.matcher(input).matches()) {
        try {
          final Transaction tx =
              new Transaction(Constants.NETWORK_PARAMETERS, Qr.decodeDecompressBinary(input));

          handleDirectTransaction(tx);
        } catch (final IOException x) {
          log.info("i/o error while fetching transaction", x);

          error(R.string.input_parser_invalid_transaction, x.getMessage());
        } catch (final ProtocolException x) {
          log.info("got invalid transaction", x);

          error(R.string.input_parser_invalid_transaction, x.getMessage());
        }
      } else {
        cannotClassify(input);
      }
    }