Reused _verifyAddress() in HandleDecodeAddress()
This commit is contained in:
parent
5925781b9a
commit
25abf66f1d
29
src/api.py
29
src/api.py
|
@ -283,11 +283,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object):
|
||||||
status, addressVersionNumber, streamNumber, ripe = \
|
status, addressVersionNumber, streamNumber, ripe = \
|
||||||
decodeAddress(address)
|
decodeAddress(address)
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
logger.warning(
|
|
||||||
'API Error 0007: Could not decode address %s. Status: %s.',
|
|
||||||
address, status
|
|
||||||
)
|
|
||||||
|
|
||||||
if status == 'checksumfailed':
|
if status == 'checksumfailed':
|
||||||
raise APIError(8, 'Checksum failed for address: ' + address)
|
raise APIError(8, 'Checksum failed for address: ' + address)
|
||||||
if status == 'invalidcharacters':
|
if status == 'invalidcharacters':
|
||||||
|
@ -312,7 +307,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object):
|
||||||
' Check the address.'
|
' 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
|
@staticmethod
|
||||||
def _dump_inbox_message(
|
def _dump_inbox_message(
|
||||||
|
@ -351,6 +352,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object):
|
||||||
|
|
||||||
# Request Handlers
|
# Request Handlers
|
||||||
|
|
||||||
|
@command('decodeAddress')
|
||||||
|
def HandleDecodeAddress(self, address):
|
||||||
|
return self._verifyAddress(address)
|
||||||
|
|
||||||
@command('listAddresses', 'listAddresses2')
|
@command('listAddresses', 'listAddresses2')
|
||||||
def HandleListAddresses(self):
|
def HandleListAddresses(self):
|
||||||
data = []
|
data = []
|
||||||
|
@ -1144,18 +1149,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler, object):
|
||||||
'softwareVersion': softwareVersion
|
'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')
|
@command('helloWorld')
|
||||||
def HandleHelloWorld(self, a, b):
|
def HandleHelloWorld(self, a, b):
|
||||||
"""Test two string params"""
|
"""Test two string params"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user