From 25abf66f1d779a2b3fb4d6b27bd3f3ba1770c878 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 29 Oct 2018 17:38:57 +0200 Subject: [PATCH] Reused _verifyAddress() in HandleDecodeAddress() --- src/api.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/api.py b/src/api.py index df364a17..c160fbfe 100644 --- a/src/api.py +++ b/src/api.py @@ -283,11 +283,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object): status, addressVersionNumber, streamNumber, ripe = \ decodeAddress(address) if status != 'success': - logger.warning( - 'API Error 0007: Could not decode address %s. Status: %s.', - address, status - ) - if status == 'checksumfailed': raise APIError(8, 'Checksum failed for address: ' + address) if status == 'invalidcharacters': @@ -312,7 +307,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object): ' Check the address.' ) - return (status, addressVersionNumber, streamNumber, ripe) + return { + 'status': status, + 'addressVersion': addressVersionNumber, + 'streamNumber': streamNumber, + 'ripe': base64.b64encode(ripe) + } if self._method == 'decodeAddress' else ( + status, addressVersionNumber, streamNumber, ripe) @staticmethod def _dump_inbox_message( @@ -351,6 +352,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object): # Request Handlers + @command('decodeAddress') + def HandleDecodeAddress(self, address): + return self._verifyAddress(address) + @command('listAddresses', 'listAddresses2') def HandleListAddresses(self): data = [] @@ -1144,18 +1149,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object): 'softwareVersion': softwareVersion } - @command('decodeAddress') - def HandleDecodeAddress(self, address): - """Handle a request to decode an address""" - # Return a meaningful decoding of an address. - status, addressVersion, streamNumber, ripe = decodeAddress(address) - return { - 'status': status, - 'addressVersion': addressVersion, - 'streamNumber': streamNumber, - 'ripe': base64.b64encode(ripe) - } - @command('helloWorld') def HandleHelloWorld(self, a, b): """Test two string params"""