Raven Core
3.0.0
P2P Digital Currency
Main Page
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
z
+
Functions
b
c
d
f
g
h
i
m
o
p
q
s
v
Variables
Typedefs
Enumerations
Enumerator
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
f
i
k
l
m
o
p
r
s
t
v
+
Enumerations
b
c
d
e
f
m
n
o
r
s
t
u
v
w
+
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Properties
+
Related Functions
a
c
d
f
o
p
t
u
v
w
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Variables
a
b
c
d
e
f
g
h
i
l
m
n
p
r
s
t
u
v
w
z
+
Typedefs
b
c
h
i
k
m
n
r
s
t
u
v
w
+
Enumerations
a
b
c
d
e
f
g
h
i
j
m
n
o
q
r
s
t
w
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
r
s
t
u
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
src
qt
ravenaddressvalidator.cpp
Go to the documentation of this file.
1
// Copyright (c) 2011-2014 The Bitcoin Core developers
2
// Copyright (c) 2017-2019 The Raven Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include "
ravenaddressvalidator.h
"
7
8
#include "
base58.h
"
9
10
/* Base58 characters are:
11
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
12
13
This is:
14
- All numbers except for '0'
15
- All upper-case letters except for 'I' and 'O'
16
- All lower-case letters except for 'l'
17
*/
18
19
RavenAddressEntryValidator::RavenAddressEntryValidator
(QObject *parent) :
20
QValidator(parent)
21
{
22
}
23
24
QValidator::State
RavenAddressEntryValidator::validate
(QString &input,
int
&pos)
const
25
{
26
Q_UNUSED(pos);
27
28
// Empty address is "intermediate" input
29
if
(input.isEmpty())
30
return
QValidator::Intermediate;
31
32
// Correction
33
for
(
int
idx = 0; idx < input.size();)
34
{
35
bool
removeChar =
false
;
36
QChar ch = input.at(idx);
37
// Corrections made are very conservative on purpose, to avoid
38
// users unexpectedly getting away with typos that would normally
39
// be detected, and thus sending to the wrong address.
40
switch
(ch.unicode())
41
{
42
// Qt categorizes these as "Other_Format" not "Separator_Space"
43
case
0x200B:
// ZERO WIDTH SPACE
44
case
0xFEFF:
// ZERO WIDTH NO-BREAK SPACE
45
removeChar =
true
;
46
break
;
47
default
:
48
break
;
49
}
50
51
// Remove whitespace
52
if
(ch.isSpace())
53
removeChar =
true
;
54
55
// To next character
56
if
(removeChar)
57
input.remove(idx, 1);
58
else
59
++idx;
60
}
61
62
// Validation
63
QValidator::State state = QValidator::Acceptable;
64
for
(
int
idx = 0; idx < input.size(); ++idx)
65
{
66
int
ch = input.at(idx).unicode();
67
68
if
(((ch >=
'0'
&& ch<=
'9'
) ||
69
(ch >=
'a'
&& ch<=
'z'
) ||
70
(ch >=
'A'
&& ch<=
'Z'
)) &&
71
ch !=
'l'
&& ch !=
'I'
&& ch !=
'0'
&& ch !=
'O'
)
72
{
73
// Alphanumeric and not a 'forbidden' character
74
}
75
else
76
{
77
state = QValidator::Invalid;
78
}
79
}
80
81
return
state;
82
}
83
84
RavenAddressCheckValidator::RavenAddressCheckValidator
(QObject *parent) :
85
QValidator(parent)
86
{
87
}
88
89
QValidator::State
RavenAddressCheckValidator::validate
(QString &input,
int
&pos)
const
90
{
91
Q_UNUSED(pos);
92
// Validate the passed Raven address
93
if
(
IsValidDestinationString
(input.toStdString())) {
94
return
QValidator::Acceptable;
95
}
96
97
return
QValidator::Invalid;
98
}
RavenAddressEntryValidator::RavenAddressEntryValidator
RavenAddressEntryValidator(QObject *parent)
Definition:
ravenaddressvalidator.cpp:19
ravenaddressvalidator.h
base58.h
RavenAddressEntryValidator::validate
State validate(QString &input, int &pos) const
Definition:
ravenaddressvalidator.cpp:24
IsValidDestinationString
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
Definition:
base58.cpp:338
RavenAddressCheckValidator::RavenAddressCheckValidator
RavenAddressCheckValidator(QObject *parent)
Definition:
ravenaddressvalidator.cpp:84
RavenAddressCheckValidator::validate
State validate(QString &input, int &pos) const
Definition:
ravenaddressvalidator.cpp:89
Generated on Mon Jul 29 2019 02:32:20 for Raven Core by
1.8.13