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(); ++idx)
26 switch(input.at(idx).unicode())
30 input[idx] = QChar('1');
34 input[idx] = QChar('o');
42 QValidator::State state = QValidator::Acceptable;
43 for(int idx=0; idx<input.size(); ++idx)
45 int ch = input.at(idx).unicode();
47 if(((ch >= '0' && ch<='9') ||
48 (ch >= 'a' && ch<='z') ||
49 (ch >= 'A' && ch<='Z')) &&
50 ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
52 // Alphanumeric and not a 'forbidden' character
56 state = QValidator::Invalid;
60 // Empty address is "intermediate" input
63 state = QValidator::Intermediate;