1 #include "bitcoinaddressvalidator.h"
3 /* Base58 characters are:
4 "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
7 - All numbers except for '0'
8 - All uppercase letters except for 'I' and 'O'
9 - All lowercase 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 // Transform characters that are visually close
33 input[idx] = QChar('1');
37 input[idx] = QChar('o');
39 // Qt categorizes these as "Other_Format" not "Separator_Space"
40 case 0x200B: // ZERO WIDTH SPACE
41 case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
58 QValidator::State state = QValidator::Acceptable;
59 for(int idx=0; idx<input.size(); ++idx)
61 int ch = input.at(idx).unicode();
63 if(((ch >= '0' && ch<='9') ||
64 (ch >= 'a' && ch<='z') ||
65 (ch >= 'A' && ch<='Z')) &&
66 ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
68 // Alphanumeric and not a 'forbidden' character
72 state = QValidator::Invalid;
76 // Empty address is "intermediate" input
79 state = QValidator::Intermediate;