From 7e07d7bc7e00deeba5571da201b5b88a7dbbfa09 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 24 Sep 2013 00:55:13 -0400 Subject: [PATCH 1/2] _verifyAddress support v4 addresses --- src/bitmessagemain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 3d7f5c73..47925a46 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -165,8 +165,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): if status == 'versiontoohigh': raise APIError(10, 'Address version number too high (or zero) in address: ' + address) raise APIError(7, 'Could not decode address: ' + address + ' : ' + status) - if addressVersionNumber < 2 or addressVersionNumber > 3: - raise APIError(11, 'The address version number currently must be 2 or 3. Others aren\'t supported. Check the address.') + if addressVersionNumber < 2 or addressVersionNumber > 4: + raise APIError(11, 'The address version number currently must be 2, 3 or 4. Others aren\'t supported. Check the address.') if streamNumber != 1: raise APIError(12, 'The stream number must be 1. Others aren\'t supported. Check the address.') From e878fb4c96f983b9b6fa426b3bc15a5aacd56a9c Mon Sep 17 00:00:00 2001 From: amos Date: Mon, 23 Sep 2013 22:35:20 -0700 Subject: [PATCH 2/2] 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)