File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
src/main/scala/io/iohk/ethereum Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ object Address {
31
31
32
32
def apply (hexString : String ): Address = {
33
33
val bytes = Hex .decode(hexString.replaceFirst(" ^0x" , " " ))
34
- require(bytes.length <= Length , s " Invalid address: $hexString" )
34
+ require(bytes.nonEmpty && bytes. length <= Length , s " Invalid address: $hexString" )
35
35
Address (bytes)
36
36
}
37
37
Original file line number Diff line number Diff line change @@ -94,15 +94,15 @@ trait JsonMethodsImplicits {
94
94
95
95
for {
96
96
from <- input.get(" from" ) match {
97
- case Some (JString (s)) => extractAddress(s)
97
+ case Some (JString (s)) if s.nonEmpty => extractAddress(s)
98
+ case Some (JString (_)) => extractAddress(" 0x0" )
98
99
case Some (_) => Left (InvalidAddress )
99
100
case _ => Left (InvalidParams (" TX 'from' is required" ))
100
101
}
101
102
102
103
to <- input.get(" to" ) match {
103
- case Some (JString (s)) =>
104
- extractAddress(s).map(Some (_))
105
-
104
+ case Some (JString (s)) if s.nonEmpty => extractAddress(s).map(Option .apply)
105
+ case Some (JString (_)) => extractAddress(" 0x0" ).map(Option .apply)
106
106
case Some (_) => Left (InvalidAddress )
107
107
case None => Right (None )
108
108
}
You can’t perform that action at this time.
0 commit comments