Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Adspromoter
ExtLibJ
Commits
cb698530
Unverified
Commit
cb698530
authored
Jan 26, 2019
by
TDevD
Committed by
GitHub
Jan 26, 2019
Browse files
Merge pull request #8 from Samourai-Wallet/develop
FormatsUtilGeneric: modify bech32 regex
parents
e8a82eeb
87fcb87f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
java/com/samourai/wallet/util/FormatsUtilGeneric.java
java/com/samourai/wallet/util/FormatsUtilGeneric.java
+19
-7
No files found.
java/com/samourai/wallet/util/FormatsUtilGeneric.java
View file @
cb698530
...
...
@@ -21,8 +21,8 @@ import java.util.regex.Pattern;
public
class
FormatsUtilGeneric
{
public
static
final
String
URI_BECH32
=
"(^bitcoin:(tb|bc)1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)(\\?amount\\=([0-9.]+))?
$
)|(^bitcoin:(TB|BC)1([QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]+)(\\?amount\\=([0-9.]+))?)"
;
public
static
final
String
URI_BECH32_LOWER
=
"^bitcoin:((tb|bc)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)(\\?amount\\=([0-9.]+))?"
;
public
static
final
String
URI_BECH32
=
"(^bitcoin:(tb|bc)1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)(\\?amount\\=([0-9.]+))?
(?s).*
)|(^bitcoin:(TB|BC)1([QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]+)(\\?amount\\=([0-9.]+))?
(?s).*
)"
;
public
static
final
String
URI_BECH32_LOWER
=
"^bitcoin:((tb|bc)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+)(\\?amount\\=([0-9.]+))?
(?s).*
"
;
public
static
final
String
HEX_REGEX
=
"^[0-9A-Fa-f]+$"
;
public
static
final
String
BASE64_REGEX
=
"^[0-9A-Za-z\\\\+=/]+$"
;
...
...
@@ -156,14 +156,26 @@ public class FormatsUtilGeneric {
if
(
s
.
toLowerCase
().
matches
(
URI_BECH32_LOWER
))
{
Pattern
pattern
=
Pattern
.
compile
(
URI_BECH32_LOWER
);
Matcher
matcher
=
pattern
.
matcher
(
s
.
toLowerCase
());
if
(
matcher
.
find
()
&&
matcher
.
group
(
4
)
!=
null
)
{
String
amt
=
matcher
.
group
(
4
);
try
{
return
Long
.
toString
(
Math
.
round
(
Double
.
valueOf
(
amt
)
*
1
e8
));
if
(
matcher
.
find
()
&&
matcher
.
group
(
3
)
!=
null
)
{
String
amt
=
null
;
int
idx
=
matcher
.
group
(
3
).
indexOf
(
"="
);
if
(
idx
!=
-
1
&&
idx
<
matcher
.
group
(
3
).
length
())
{
amt
=
matcher
.
group
(
3
).
substring
(
idx
+
1
);
}
if
(
amt
!=
null
)
{
try
{
return
Long
.
toString
(
Math
.
round
(
Double
.
valueOf
(
amt
)
*
1
e8
));
}
catch
(
NumberFormatException
nfe
)
{
ret
=
"0.0000"
;
}
}
catch
(
NumberFormatException
nfe
)
{
else
{
ret
=
"0.0000"
;
}
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment