Skip to content

Commit

Permalink
Merge master and resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed Apr 7, 2024
2 parents 482e9bc + 2d7e2f2 commit 5c7e102
Show file tree
Hide file tree
Showing 19 changed files with 1,027 additions and 1,115 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
RELEASE 0.6.15 - Small bugfixes, documentation updates
======================================================
* Some small bugfixes
* New properties for WalletKey class for multisig wallets
* Add Bcoin documentation, add FAQ, update other documentation
* Add dockerfile for Linux Mint

RELEASE 0.6.14 - Update installation instruction, docker & bugfixes
===================================================================
* Update installation instructions
Expand Down
38 changes: 23 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ Python Bitcoin Library
Bitcoin cryptocurrency Library writen in Python.

Allows you to create a fully functional Bitcoin wallet with a single line of code.
Use this library to create and manage transactions, addresses/keys, wallets, mnemonic password phrases and blocks with
simple and straightforward Python code.
Use this library to create and manage transactions, addresses/keys, wallets, mnemonic password phrases
and blocks with simple and straightforward Python code.

You can use this library at a high level and create and manage wallets from the command line or at a low level
and create your own custom made transactions, scripts, keys or wallets.

The BitcoinLib connects to various service providers automatically to update wallets, transaction and
blockchain information.
blockchain information. You can also connect to a local
`Bitcoin <https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.setup-bitcoind-connection.html>`_ or
`Bcoin node <https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.setup-bcoin.html>`_.


.. image:: https://github.com/1200wd/bitcoinlib/actions/workflows/unittests.yaml/badge.svg
:target: https://github.com/1200wd/bitcoinlib/actions/workflows/unittests.yaml
Expand All @@ -30,7 +33,7 @@ blockchain information.
Install
-------

Installed required packages
Install required packages on Ubuntu or related Linux systems:

.. code-block:: bash
Expand All @@ -42,9 +45,11 @@ Then install using pip
$ pip install bitcoinlib
For more detailed installation instructions, how to install on other systems or troubleshooting please read https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.install.html
Check out the `more detailed installation instructions <https://bitcoinlib.readthedocs.io/en/latest/source/_static/manuals.install.html>`_ to read how to install on other systems or for
troubleshooting.

If you are using docker you can check some Dockerfiles to create images in the docker directory.
If you are using docker you can check some Dockerfiles to create images in the
`docker <https://github.com/1200wd/bitcoinlib/tree/master/docker>`_ directory.

Documentation
-------------
Expand All @@ -65,7 +70,7 @@ Example: Create wallet and generate new address (key) to receive bitcoins
>>> from bitcoinlib.wallets import Wallet
>>> w = Wallet.create('Wallet1')
>>> w.get_key().address
'1Fo7STj6LdRhUuD1AiEsHpH65pXzraGJ9j'
'bc1qk25wwkvz3am9smmm3372xct5s7cwf0hmnq8szj'
Now send a small transaction to your wallet and use the scan() method to update transactions and UTXO's

Expand All @@ -79,23 +84,27 @@ If successful a transaction ID is returned

.. code-block:: pycon
>>> t = w.send_to('1PWXhWvUH3bcDWn6Fdq3xhMRPfxRXTjAi1', '0.001 BTC', offline=False)
>>> t = w.send_to('bc1qemtr8ywkzg483g8m34ukz2l4pl3730776vzq54', '0.001 BTC', offline=False)
'b7feea5e7c79d4f6f343b5ca28fa2a1fcacfe9a2b7f44f3d2fd8d6c2d82c4078'
>>> t.info # Shows transaction information and send results
More examples
-------------

Checkout the documentation page https://bitcoinlib.readthedocs.io/en/latest/ or take a look at some
more examples at https://github.com/1200wd/bitcoinlib/tree/master/examples
You can find many more examples in the `documentation <https://bitcoinlib.readthedocs.io/en/latest/>`_
for instance about the `Wallet.create() <https://bitcoinlib.readthedocs.io/en/latest/source/bitcoinlib.wallets.html#bitcoinlib.wallets.Wallet.create>`_ method.

There are many working examples on how to create wallets, specific transactions, encrypted databases, parse the
blockchain, connect to specific service providers in the `examples directory <https://github.com/1200wd/bitcoinlib/tree/master/examples>`_ in the source code of this library.

Some more specific examples can be found on the `Coineva website <https://coineva.com/category/bitcoinlib.html>`_.

Contact
-------

If you have any questions, encounter a problem or want to share an idea, please use Github Discussions
https://github.com/1200wd/bitcoinlib/discussions
If you have any questions, encounter a problem or want to share an idea, please use `Github Discussions
<https://github.com/1200wd/bitcoinlib/discussions>`_


Implements the following Bitcoin Improvement Proposals
Expand All @@ -115,13 +124,12 @@ Implements the following Bitcoin Improvement Proposals
Future / Roadmap
----------------

- Support advanced scripts
- Fully support timelocks
- Support for lightning network
- Support Taproot and Schnorr signatures
- Support advanced scripts
- Support for Trezor wallet or other hardware wallets
- Allow to scan full blockchain
- Integrate simple SPV client
- Support Schnorr signatures


Disclaimer
Expand Down
2 changes: 1 addition & 1 deletion bitcoinlib/config/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.14
0.6.15
17 changes: 9 additions & 8 deletions bitcoinlib/services/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ class BitcoindClient(BaseClient):
"""

@staticmethod
def from_config(configfile=None, network='bitcoin', *args):
@deprecated
def from_config(configfile=None, network='bitcoin', **kwargs):
"""
Read settings from bitcoind config file
Obsolete: does not work anymore, passwords are not stored in bitcoin config, only hashed password.
:param configfile: Path to config file. Leave empty to look in default places
:type: str
:param network: Bitcoin mainnet or testnet. Default is bitcoin mainnet
Expand Down Expand Up @@ -113,7 +116,7 @@ def from_config(configfile=None, network='bitcoin', *args):
server = _read_from_config(config, 'rpc', 'externalip', server)

url = "http://%s:%s@%s:%s" % (config.get('rpc', 'rpcuser'), config.get('rpc', 'rpcpassword'), server, port)
return BitcoindClient(network, url, *args)
return BitcoindClient(network, url, **kwargs)

def __init__(self, network='bitcoin', base_url='', denominator=100000000, *args):
"""
Expand All @@ -129,6 +132,7 @@ def __init__(self, network='bitcoin', base_url='', denominator=100000000, *args)
if isinstance(network, Network):
network = network.name
if not base_url:
_logger.warning("Please provide rpc connection url to bitcoind node")
bdc = self.from_config('', network)
base_url = bdc.base_url
network = bdc.network
Expand Down Expand Up @@ -332,12 +336,9 @@ def getinfo(self):

from pprint import pprint

# 1. Connect by specifying connection URL
# base_url = 'http://bitcoinrpc:passwd@host:8332'
# bdc = BitcoindClient(base_url=base_url)

# 2. Or connect using default settings or settings from config file
bdc = BitcoindClient()
# Connect by specifying connection URL
base_url = 'http://bitcoinrpc:passwd@host:8332'
bdc = BitcoindClient(base_url=base_url)

print("\n=== SERVERINFO ===")
pprint(bdc.proxy.getnetworkinfo())
Expand Down
10 changes: 8 additions & 2 deletions bitcoinlib/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Service(object):

def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, providers=None,
timeout=TIMEOUT_REQUESTS, cache_uri=None, ignore_priority=False, exclude_providers=None,
max_errors=SERVICE_MAX_ERRORS, strict=True):
max_errors=SERVICE_MAX_ERRORS, strict=True, wallet_name=None):
"""
Create a service object for the specified network. By default, the object connect to 1 service provider, but you
can specify a list of providers or a minimum or maximum number of providers.
Expand Down Expand Up @@ -131,6 +131,7 @@ def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, pr
self._blockcount = None
self.cache = None
self.cache_uri = cache_uri
self.wallet_name = wallet_name
try:
self.cache = Cache(self.network, db_uri=cache_uri)
except Exception as e:
Expand Down Expand Up @@ -166,8 +167,13 @@ def _provider_execute(self, method, *arguments):
continue
client = getattr(services, self.providers[sp]['provider'])
providerclient = getattr(client, self.providers[sp]['client_class'])

base_url = self.providers[sp]['url']
if 'bitcoind' in sp and self.wallet_name is not None:
base_url = f"{base_url}/wallet/{self.wallet_name}"

pc_instance = providerclient(
self.network, self.providers[sp]['url'], self.providers[sp]['denominator'],
self.network, base_url, self.providers[sp]['denominator'],
self.providers[sp]['api_key'], self.providers[sp]['provider_coin_id'],
self.providers[sp]['network_overrides'], self.timeout, self._blockcount, self.strict)
if not hasattr(pc_instance, method):
Expand Down
Loading

0 comments on commit 5c7e102

Please sign in to comment.