MCPcopy
hub / github.com/petertodd/python-bitcoinlib / _call

Method _call

bitcoin/rpc.py:229–260  ·  view source on GitHub ↗
(self, service_name, *args)

Source from the content-addressed store, hash-verified

227 timeout=timeout)
228
229 def _call(self, service_name, *args):
230 self.__id_count += 1
231
232 postdata = json.dumps({'version': '1.1',
233 'method': service_name,
234 'params': args,
235 'id': self.__id_count})
236
237 headers = {
238 'Host': self.__url.hostname,
239 'User-Agent': DEFAULT_USER_AGENT,
240 'Content-type': 'application/json',
241 }
242
243 if self.__auth_header is not None:
244 headers['Authorization'] = self.__auth_header
245
246 self.__conn.request('POST', self.__url.path, postdata, headers)
247
248 response = self._get_response()
249 err = response.get('error')
250 if err is not None:
251 if isinstance(err, dict):
252 raise JSONRPCError(
253 {'code': err.get('code', -345),
254 'message': err.get('message', 'error message not specified')})
255 raise JSONRPCError({'code': -344, 'message': str(err)})
256 elif 'result' not in response:
257 raise JSONRPCError({
258 'code': -343, 'message': 'missing JSON-RPC result'})
259 else:
260 return response['result']
261
262 def _batch(self, rpc_call_list):
263 postdata = json.dumps(list(rpc_call_list))

Callers 15

__getattr__Method · 0.45
callMethod · 0.45
dumpprivkeyMethod · 0.45
fundrawtransactionMethod · 0.45
generateMethod · 0.45
generatetoaddressMethod · 0.45
getaccountaddressMethod · 0.45
getbalanceMethod · 0.45
getbestblockhashMethod · 0.45
getblockheaderMethod · 0.45
getblockMethod · 0.45
getblockcountMethod · 0.45

Calls 2

_get_responseMethod · 0.95
JSONRPCErrorClass · 0.85

Tested by

no test coverage detected