MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / Proxy

Class Proxy

bitcoin/rpc.py:338–797  ·  view source on GitHub ↗

Proxy to a bitcoin RPC service Unlike ``RawProxy``, data is passed as ``bitcoin.core`` objects or packed bytes, rather than JSON or hex strings. Not all methods are implemented yet; you can use ``call`` to access missing ones in a forward-compatible way. Assumes Bitcoin Core version

Source from the content-addressed store, hash-verified

336
337
338class Proxy(BaseProxy):
339 """Proxy to a bitcoin RPC service
340
341 Unlike ``RawProxy``, data is passed as ``bitcoin.core`` objects or packed
342 bytes, rather than JSON or hex strings. Not all methods are implemented
343 yet; you can use ``call`` to access missing ones in a forward-compatible
344 way. Assumes Bitcoin Core version >= v0.16.0; older versions mostly work,
345 but there are a few incompatibilities.
346 """
347
348 def __init__(self,
349 service_url=None,
350 service_port=None,
351 btc_conf_file=None,
352 timeout=DEFAULT_HTTP_TIMEOUT,
353 **kwargs):
354 """Create a proxy object
355
356 If ``service_url`` is not specified, the username and password are read
357 out of the file ``btc_conf_file``. If ``btc_conf_file`` is not
358 specified, ``~/.bitcoin/bitcoin.conf`` or equivalent is used by
359 default. The default port is set according to the chain parameters in
360 use: mainnet, testnet, signet, or regtest.
361
362 Usually no arguments to ``Proxy()`` are needed; the local bitcoind will
363 be used.
364
365 ``timeout`` - timeout in seconds before the HTTP interface times out
366 """
367
368 super(Proxy, self).__init__(service_url=service_url,
369 service_port=service_port,
370 btc_conf_file=btc_conf_file,
371 timeout=timeout,
372 **kwargs)
373
374 def call(self, service_name, *args):
375 """Call an RPC method by name and raw (JSON encodable) arguments"""
376 return self._call(service_name, *args)
377
378 def dumpprivkey(self, addr):
379 """Return the private key matching an address
380 """
381 r = self._call('dumpprivkey', str(addr))
382
383 return CBitcoinSecret(r)
384
385 def fundrawtransaction(self, tx, include_watching=False):
386 """Add inputs to a transaction until it has enough in value to meet its out value.
387
388 include_watching - Also select inputs which are watch only
389
390 Returns dict:
391
392 {'tx': Resulting tx,
393 'fee': Fee the resulting transaction pays,
394 'changepos': Position of added change output, or -1,
395 }

Callers 2

spend-p2wpkh.pyFile · 0.90
payment_requestFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected