Skip to content

Conversation

bigshiny90
Copy link

@bigshiny90 bigshiny90 commented Sep 10, 2025

Fixes #166

QValidatedLineEdit:

  1. Added setAllowEmptyInput() to QValidatedLineEdit to allow it to treat empty values as valid or invalid. Required for empty proxy values to be considered not valid. Default is true to conform to other usage in the code.
  2. Added setAllowValidationWhileEditing to allow for live validation while editing (default is false, to not break other usage in code). Previously it only validated on FocusOut. This was required for OptionsDialog proxy settings otherwise edge-case where editing a proxy field and then clicking OK (without explicitly changing focus beforehand) resulted in no validation and acceptance of invalid values.
  3. Removed forcing error_locations after calling validate with validator's that do not actually support error_locations. (Bitcoin address validator is explicitly handled and does support error locations)
  4. clears invalid styling when disabling

OptionsDialog

  1. Fixed QValidatedLineEdit Socks Proxy and Tor proxy input validation to properly validate and show visual feedback. These input fields are QValidatedLineEdit instances but were not previously validating the input (fully) or giving validation feedback. Empty values were previously considered valid but this has been fixed. Added validation of IPv4 style input using inet_pton
  2. Added setAllowEmptyInput(false) to proxy fields to allow them to treat empty values as valid or invalid. Required for empty proxy values to be considered not valid.
  3. Added setAllowValidationWhileEditing(true) for validation while editing
  4. Also fixed theme change handling to update invalid qvalidated colors correctly (knots specific)
  5. Fixed checkbox-dependent saving behavior for proxy settings - previously empty or invalid values were saved, even if the associated checkbox was unchecked. Now, if the associated checkbox is unchecked, values (whether valid or invalid) are ignored.
  6. Added QT6 check for connecting socks and tor proxy checkboxes properly. follows the same pattern that @luke-jr used for the prune checkbox. Needed for calls to qvalidatedlineedit setEnabled() to work properly.

@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from 35123a8 to b379c2c Compare September 10, 2025 19:47
@1440000bytes
Copy link

1440000bytes commented Sep 11, 2025

Tested v29.1 and PR branch. This pull request fixes the proxy validation in GUI although I am not sure about the approach.

image image

@1440000bytes
Copy link

Note: We can use multiple proxies in v29.1 although GUI doesn't support this yet and it would be out of scope for this pull request.

https://github.com/bitcoinknots/bitcoin/blob/v29.1.knots20250903/doc/release-notes.md#updated-settings

@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from b379c2c to ca057ff Compare September 11, 2025 18:22
@bigshiny90
Copy link
Author

bigshiny90 commented Sep 11, 2025

i'm glad you posted the screenshots.. it pointed out an edge case that should NOT be happening - the proxy fields (QValidatedLineEdit widgets) did NOT originally validate until after focusOut. This leads to an edge case where you can input invalid IP or Port and then click OK to save the invalid data.

This is fixed in this latest version.

Also, found a bug where the checkboxes connect code was incorrect with >=QT6.7.. Luke has a fix for this already for OptionsDialog 'prune' checkbox. Had to use this pattern to cover the connectSocks and connectSocksTor checkboxes.

Lastly, the proxyvalidator used here does not mark 'error locations' and the default behavior of QValidatedLineEdit is to always set the first character position as an error, then marking the first char of the string as invalid (red, underlined, bold). Most validators don't do this - except the bitcoin address validator. So, i've changed qvalidatedlineedit to not mark ANY chars as 'errors' as it doesn't make sense. i.e. only validators that support error locations should result in the chars in the string being marked as errors. Another approach might be to extend ProxyValidator to actually support error locations, which gives visual feedback (red text) indicating problem parts of the string. seemed overly complicated for this use case, but the possibility is there.

@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from ca057ff to db24f29 Compare September 11, 2025 18:49
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from db24f29 to ddf80f5 Compare September 12, 2025 18:23
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from ddf80f5 to bcba04c Compare September 13, 2025 14:12
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from bcba04c to 0839298 Compare September 15, 2025 12:53
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from 0839298 to acd88f2 Compare September 16, 2025 12:21
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from acd88f2 to 2cafcb8 Compare September 16, 2025 18:38
Copy link

@Ataraxia009 Ataraxia009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Tested, everything looks fine

Side note:
There is a bug on how signverifymessagedialogue handles changing the window to any other app on your computer and then coming back to bitcoin knots.
But this is out of scope for this PR

Copy link

@1440000bytes 1440000bytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 2cafcb8

@bigshiny90
Copy link
Author

Quick note: I had been thinking the original validation code handled hostnames…but when reviewing, turns out it didn’t. Hence, after changes to use inet_pton, the original code was redundant - it was just using NumericLookup to validate numeric input, but less competently than inet pton

… highlighting

- Add setAllowEmptyInput() to control whether empty input is valid
- Add setAllowValidationWhileEditing() for real-time validation
- Fix focusInEvent to handle validation-while-editing fields correctly
- Fix setEnabled to clear focus before disabling to ensure proper cleanup of invalid visual state
- Add changeEvent() handler to update validation colors on palette/theme changes
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from 2cafcb8 to 22b37db Compare September 25, 2025 13:27
  - Enable validation while typing for proxy fields (proxyIp, proxyPort, proxyIpTor, proxyPortTor)
  - Fix checkbox signal handling for Qt 6.7+ compatibility
  - Ensure proxy fields are properly enabled/disabled based on checkbox state
@bigshiny90 bigshiny90 force-pushed the v29.1-optionsdialog-validation-fixes branch from 22b37db to bb70122 Compare September 25, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No text input validation on proxyip settings
4 participants