1 #include "bitcoinaddressvalidator.h"
3 /* Base58 characters are:
4 "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
7 - All numbers except for '0'
8 - All upper-case letters except for 'I' and 'O'
9 - All lower-case letters except for 'l'
11 User friendly Base58 input can map
16 BitcoinAddressValidator::BitcoinAddressValidator(QObject *parent) :
21 QValidator::State BitcoinAddressValidator::validate(QString &input, int &pos) const
24 for(int idx=0; idx<input.size();)
26 bool removeChar = false;
27 QChar ch = input.at(idx);
28 // Corrections made are very conservative on purpose, to avoid
29 // users unexpectedly getting away with typos that would normally
30 // be detected, and thus sending to the wrong address.
33 // Qt categorizes these as "Other_Format" not "Separator_Space"
34 case 0x200B: // ZERO WIDTH SPACE
35 case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
52 QValidator::State state = QValidator::Acceptable;
53 for(int idx=0; idx<input.size(); ++idx)
55 int ch = input.at(idx).unicode();
57 if(((ch >= '0' && ch<='9') ||
58 (ch >= 'a' && ch<='z') ||
59 (ch >= 'A' && ch<='Z')) &&
60 ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
62 // Alphanumeric and not a 'forbidden' character
66 state = QValidator::Invalid;
70 // Empty address is "intermediate" input
73 state = QValidator::Intermediate;