From e878fb4c96f983b9b6fa426b3bc15a5aacd56a9c Mon Sep 17 00:00:00 2001 From: amos Date: Mon, 23 Sep 2013 22:35:20 -0700 Subject: [PATCH] Add api method decodeAddress Add decodeAddress as an api call. Like the addresses.decodeAddress function it return status, addressVersion, streamNumber, and ripe. ripe is base64 encoded. --- src/bitmessagemain.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 47925a46..2e7bb9af 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -818,6 +818,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): else: networkStatus = 'connectedAndReceivingIncomingConnections' return json.dumps({'networkConnections':len(shared.connectedHostsList),'numberOfMessagesProcessed':shared.numberOfMessagesProcessed, 'numberOfBroadcastsProcessed':shared.numberOfBroadcastsProcessed, 'numberOfPubkeysProcessed':shared.numberOfPubkeysProcessed, 'networkStatus':networkStatus, 'softwareName':'PyBitmessage','softwareVersion':shared.softwareVersion}, indent=4, separators=(',', ': ')) + elif method == 'decodeAddress': + #decode an address + if len(params) != 1: + raise APIError(0, 'I need 1 parameter!') + address, = params + status, addressVersion, streamNumber, ripe = decodeAddress(address) + return json.dumps({'status':status, 'addressVersion':addressVersion, + 'streamNumber':streamNumber, 'ripe':ripe.encode('base64')}, indent=4, + separators=(',', ': ')) else: raise APIError(20, 'Invalid method: %s' % method)