diff --git a/contracts/RLP.sol b/contracts/RLP.sol index c5a7bb2..62efd49 100644 --- a/contracts/RLP.sol +++ b/contracts/RLP.sol @@ -289,14 +289,10 @@ library RLP { /// @param self The RLPItem. /// @return The decoded string. function toAddress(RLPItem memory self) internal constant returns (address data) { - if(!isData(self)) - throw; - var (rStartPos, len) = _decode(self); - if (len != 20) + var (, len) = _decode(self); + if (len > 20) throw; - assembly { - data := div(mload(rStartPos), exp(256, 12)) - } + return address(toUint(self)); } // Get the payload offset. @@ -411,4 +407,4 @@ library RLP { return false; return true; } -} \ No newline at end of file +}