From 077d6b32e519e86d3dd9469db5ca0b58c6d9e843 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Sun, 28 Oct 2018 00:21:07 +0300 Subject: [PATCH] Fix short address decoding (develop branch) Example addresses: ``` 0x0014F55A50b281EFD12294f0Cda821Bd8171e920 0x0000000000000000000000000000000000000000 ``` --- contracts/SmartPool.sol | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/contracts/SmartPool.sol b/contracts/SmartPool.sol index b0b8b7e..037f38a 100644 --- a/contracts/SmartPool.sol +++ b/contracts/SmartPool.sol @@ -302,14 +302,10 @@ library RLP { /// @param self The RLPItem. /// @return The decoded string. function toAddress(RLPItem memory self) internal pure returns (address data) { - if(!isData(self)) - revert(); - var (rStartPos, len) = _decode(self); - if (len != 20) + var (, len) = _decode(self); + if (len > 20) revert(); - assembly { - data := div(mload(rStartPos), exp(256, 12)) - } + return address(toUint(self)); } // Get the payload offset.