Sitelet https://github.com/jgarzik/python-bitcoinrpc/commit/5409b02a673be294c06bd757d40d60169e6767f4
Skip to content

Commit 5409b02

Browse files
committed
If RPC response doesn't have {error:} throws error
When trying to communicate to a node.js RPC server, a Key Error: error would be thrown.
1 parent f607fe7 commit 5409b02

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎bitcoinrpc/authproxy.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ def __call__(self, *args):
134134
'Content-type': 'application/json'})
135135

136136
response = self._get_response()
137-
if response['error'] is not None:
138-
raise JSONRPCException(response['error'])
137+
if 'error' in response:
138+
if response['error'] is not None:
139+
raise JSONRPCException(response['error'])
139140
elif 'result' not in response:
140141
raise JSONRPCException({
141142
'code': -343, 'message': 'missing JSON-RPC result'})

0 commit comments

Comments
 (0)