Metadata-Version: 2.1
Name: planetmint-driver
Version: 0.14.0
Summary: Python driver for Planetmint
Home-page: https://github.com/planetmint/planetmint-driver
Author: Planetmint
Author-email: contact@ipdb.global
License: Apache Software License 2.0
Keywords: planetmint_driver
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
Provides-Extra: test
Provides-Extra: dev
Provides-Extra: docs
License-File: LICENSE
License-File: AUTHORS.rst


.. Copyright Planetmint GmbH and Planetmint contributors
   SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
   Code is Apache-2.0 and docs are CC-BY-4.0

.. image:: https://badges.gitter.im/planetmint/planetmint-driver.svg
   :alt: Join the chat at https://gitter.im/planetmint/planetmint-driver
   :target: https://gitter.im/planetmint/planetmint-driver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge


.. image:: https://badge.fury.io/py/planetmint-driver.svg
    :target: https://badge.fury.io/py/planetmint-driver

.. image:: https://app.travis-ci.com/planetmint/planetmint-driver.svg?branch=main
    :target: https://app.travis-ci.com/planetmint/planetmint-driver

.. image:: https://img.shields.io/codecov/c/github/planetmint/planetmint-driver/master.svg
    :target: https://codecov.io/github/planetmint/planetmint-driver?branch=master


Planetmint Python Driver
==========================

* Free software: Apache Software License 2.0
* Check our `Documentation`_

.. contents:: Table of Contents


Features
--------

* Support for preparing, fulfilling, and sending transactions to a Planetmint
  node.
* Retrieval of transactions by id.

Install
----------

The instructions below were tested on Ubuntu 16.04 LTS. They should also work on other Linux distributions and on macOS. The driver might work on Windows as well, but we do not guarantee it. We recommend to set up (e.g. via Docker on Windows) an Ubuntu VM there.

We recommend you use a virtual environment to install and update to the latest stable version using `pip` (or `pip3`):

.. code-block:: text

    pip install -U planetmint-driver

That will install the latest *stable* Planetmint Python Driver. If you want to install an Alpha, Beta or RC version of the Python Driver, use something like:

.. code-block:: text

    pip install -U planetmint_driver==0.11.1

The above command will install version 0.11.1. You can find a list of all versions in `the release history page on PyPI <https://pypi.org/project/planetmint-driver/#history>`_.

More information on how to install the driver can be found in the `Quickstart`_

Planetmint Documentation
------------------------------------
* `Planetmint Server Quickstart`_
* `The Hitchhiker's Guide to Planetmint`_
* `HTTP API Reference`_
* `All Planetmint Documentation`_

Usage
----------
Example: Create a divisible asset for Alice who issues 10 token to Bob so that he can use her Game Boy.
Afterwards Bob spends 3 of these tokens.

If you want to send a transaction you need to `Determine the Planetmint Root URL`_.

.. code-block:: python

    # import Planetmint and create an object
    from planetmint_driver import Planetmint
    bdb_root_url = 'https://example.com:9984'
    bdb = Planetmint(bdb_root_url)

    # generate a keypair
    from planetmint_driver.crypto import generate_keypair
    alice, bob = generate_keypair(), generate_keypair()

    # create a digital asset for Alice
    game_boy_token = {
        'data': {
            'token_for': {
                'game_boy': {
                    'serial_number': 'LR35902'
                }
            },
            'description': 'Time share token. Each token equals one hour of usage.',
        },
    }

    # prepare the transaction with the digital asset and issue 10 tokens for Bob
    prepared_token_tx = bdb.transactions.prepare(
        operation='CREATE',
        signers=alice.public_key,
        recipients=[([bob.public_key], 10)],
        asset=game_boy_token)

    # fulfill and send the transaction
    fulfilled_token_tx = bdb.transactions.fulfill(
        prepared_token_tx,
        private_keys=alice.private_key)
    bdb.transactions.send_commit(fulfilled_token_tx)

    # Use the tokens
    # create the output and inout for the transaction
    transfer_asset = {'id': fulfilled_token_tx['id']}
    output_index = 0
    output = fulfilled_token_tx['outputs'][output_index]
    transfer_input = {'fulfillment': output['condition']['details'],
                      'fulfills': {'output_index': output_index,
                                   'transaction_id': transfer_asset['id']},
                      'owners_before': output['public_keys']}

    # prepare the transaction and use 3 tokens
    prepared_transfer_tx = bdb.transactions.prepare(
        operation='TRANSFER',
        asset=transfer_asset,
        inputs=transfer_input,
        recipients=[([alice.public_key], 3), ([bob.public_key], 7)])

    # fulfill and send the transaction
    fulfilled_transfer_tx = bdb.transactions.fulfill(
        prepared_transfer_tx,
        private_keys=bob.private_key)
    sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)

Compatibility Matrix
--------------------

+-----------------------+---------------------------+
| **Planetmint Server** | **Planetmint Driver**     |
+=======================+===========================+
| ``>= 2.0.0b7``        | ``0.6.2``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b7``        | ``0.6.1``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b7``        | ``0.6.0``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.3``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.2``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b5``        | ``0.5.1``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0b1``        | ``0.5.0``                 |
+-----------------------+---------------------------+
| ``>= 2.0.0a3``        | ``0.5.0a4``               |
+-----------------------+---------------------------+
| ``>= 2.0.0a2``        | ``0.5.0a2``               |
+-----------------------+---------------------------+
| ``>= 2.0.0a1``        | ``0.5.0a1``               |
+-----------------------+---------------------------+
| ``>= 1.0.0``          | ``0.4.x``                 |
+-----------------------+---------------------------+
| ``== 1.0.0rc1``       | ``0.3.x``                 |
+-----------------------+---------------------------+
| ``>= 0.9.1``          | ``0.2.x``                 |
+-----------------------+---------------------------+
| ``>= 0.8.2``          | ``>= 0.1.3``              |
+-----------------------+---------------------------+

`Although we do our best to keep the master branches in sync, there may be
occasional delays.`

License
--------
* `licenses`_ - open source & open content

Credits
-------

This package was initially created using Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. Many Planetmint developers have contributed since then.

.. _Documentation: https://docs.planetmint.com/projects/py-driver/
.. _pypi history: https://pypi.org/project/planetmint-driver/#history
.. _Quickstart: https://docs.planetmint.com/projects/py-driver/en/latest/quickstart.html
.. _Planetmint Server Quickstart: https://docs.planetmint.com/projects/server/en/latest/quickstart.html
.. _The Hitchhiker's Guide to Planetmint: https://www.planetmint.com/developers/guide/
.. _HTTP API Reference: https://docs.planetmint.com/projects/server/en/latest/http-client-server-api.html
.. _All Planetmint Documentation: https://docs.planetmint.com/
.. _Determine the Planetmint Root URL: https://docs.planetmint.com/projects/py-driver/en/latest/connect.html
.. _licenses: https://github.com/planetmint/planetmint-driver/blob/master/LICENSES.md
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage



.. Copyright Planetmint GmbH and Planetmint contributors
   SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
   Code is Apache-2.0 and docs are CC-BY-4.0

Changelog
=========

0.14.0 (2022-12-02)
-------------------
Fixed
^^^^^
* reintegrated delegated signing support into the driver


0.13.0 (2022-11-28)
-------------------
Changed
^^^^^^^
* adjusted to changes in planetmint-transactions@0.2.2 that are a result from the zenroom upgrade and package renaming

0.12.0 (2022-10-27)
-------------------
Changed
^^^^^^^
* replaced common module with planetmint-transactions package
* adjusted for asset changes in planetmint-transactions@0.2.0

0.11.0 (2022-09-15)
-------------------
Changed
^^^^^^^
* Breaking: fixed the faulty default placemnt of the "data"-tag into assets. Thereby caused obfuscation got removed.
* Breaking: adjusted to the IPLD definitions of planetmint.

0.6.2 (2022-09-08)
------------------
Changed
^^^^^^^
* In setup.py, changed crypto-conditions dependency to above 0.10.0


0.6.2 (2018-11-03)
------------------
Changed
^^^^^^^
* In setup.py, changed python-rapidjson==0.6.0 to ~=0.6.0,
  and changed requests>=2.11.0 to >=2.20.0

0.6.1 (2018-10-21)
------------------
Fixed
^^^^^
* Fixed the problem with a docs page (Handcrafting Transactions) that wouldn't build.

0.6.0 (2018-10-20)
------------------
Changed
^^^^^^^
* Added support for deterministic keypair generation from a 32-byte seed.
  See pull request #487 by external contributor @excerebrose
* Pinned cryptoconditions==0.8.0 in setup.py

Removed
^^^^^^^
* The send() function was removed. See pull request #483.

Known issues
^^^^^^^^^^^^
* Builds of the Handcrafting Transactions page started failing again,
  in Travis CI and on ReadTheDocs.

0.5.3 (2018-09-12)
------------------
Changed
^^^^^^^
* Fixed a failing unit test
* Pinned cryptoconditions==0.7.2 in setup.py
* Fixed the Handcrafting Transactions page in the docs

0.5.2 (2018-08-31)
-------------------
Added
^^^^^

* Cap exponential backoff depending on timeout value for reasonable waiting time in event of network recovery. `#470 <https://github.com/planetmint/planetmint-driver/pull/470>`
* Update cryptoconditions dependency because of security vulnerability CVE-2018-10903. `#472 <https://github.com/planetmint/planetmint-driver/pull/472>`


0.5.1 (2018-08-23)
---------------------
Added
^^^^^

* Support for Planetmint server v2.0.0.b5.
* added round-robin strategy to connect to nodes of the Planetmint network `BEP 14 <https://github.com/planetmint/BEPs/tree/master/14>`_

0.5.0 (2018-06-14)
---------------------
Added
^^^^^
* Added three new methods to send/post a transaction as discussed `here <https://github.com/planetmint/planetmint/issues/2307>`_:

    * ``send_commit``
    * ``send_async``
    * ``send_sync``

Deprecated
^^^^^^^^^^
* ``send()`` under ``TransactionEndpoint``, and available
  via ``Planetmint.transactions``. Replaced by the above three methods:
  ``send_commit()``, ``send_async()``, and ``send_sync()``.


0.5.0a4 (2018-05-07)
---------------------
* `Removed dependencies from Planetmint Server package <https://github.com/planetmint/planetmint-driver/pull/411>`_.


0.5.0a2 (2018-04-18)
---------------------
* `The default mode for sending a transaction is now commit <https://github.com/planetmint/planetmint-driver/issues/386>`_.
* `The metadata endpoint was added <https://github.com/planetmint/planetmint-driver/issues/347>`_.
* Support for Planetmint server v2.0.0a2.


0.5.0a1 (2018-04-03)
--------------------
There were **many** changes between Planetmint 1.3 and Planetmint 2.0 Alpha, too many to list here. We wrote a series of blog posts to summarize most changes, especially those that affect end users and application developers:

* `Some HTTP API Changes in the Next Release <https://blog.planetmint.com/some-http-api-changes-in-the-next-release-49612a537b0c>`_.
* `Three Transaction Model Changes in the Next Release <https://blog.planetmint.com/three-transaction-model-changes-in-the-next-release-dadbac50094a>`_.


0.4.1 (2017-08-02)
------------------
Fixed
^^^^^
* Handcrafting transactions documentation. `Pull request #312
  <https://github.com/planetmint/planetmint-driver/pull/312>`_.
* Quickstart guide. `Pull request #316
  <https://github.com/planetmint/planetmint-driver/pull/316>`_.

0.4.0 (2017-07-05)
------------------
Added
^^^^^
* Support for Planetmint server (HTTP API) 1.0.0.

0.3.0 (2017-06-23)
------------------
Added
^^^^^
* Support for Planetmint server (HTTP API) 1.0.0rc1.
* Support for crypto-conditions RFC draft version 02.
* Added support for text search endpoint ``/assets?search=``

0.2.0 (2017-02-06)
------------------
Added
^^^^^
* Support for Planetmint server 0.9.
* Methods for ``GET /`` and ``GET /api/v1``

Changed
^^^^^^^
* Node URLs, passed to ``Planetmint()`` MUST not include the api prefix
  ``'/api/v1'``, e.g.:

    * BEFORE: ``http://localhost:9984/api/v1``
    * NOW: ``http://localhost:9984``

0.1.0 (2016-11-29)
------------------
Added
^^^^^
* Support for Planetmint server 0.8.0.
* Support for divisible assets.

Removed
^^^^^^^
* ``create()`` and ``transfer()`` under ``TransactionEndpoint``, and available
  via ``Planetmint.transactions``. Replaced by the three "canonical"
  transaction operations: ``prepare()``, ``fulfill()``, and ``send()``.
* Support for client side timestamps.


0.0.3 (2016-11-25)
------------------
Added
^^^^^
* Support for "canonical" transaction operations:

    * ``prepare``
    * ``fulfill``
    * ``send``

Deprecated
^^^^^^^^^^
* ``create()`` and ``transfer()`` under ``TransactionEndpoint``, and available
  via ``Planetmint.transactions``. Replaced by the above three "canonical"
  transaction operations: ``prepare()``, ``fulfill()``, and ``send()``.

Fixed
^^^^^
* ``Planetmint()`` default node setting on its transport class. See commit
  `0a80206 <https://github.com/planetmint/planetmint-driver/commit/0a80206407ef155d220d25a337dc9a4f51046e70>`_


0.0.2 (2016-10-28)
------------------

Added
^^^^^
* Support for Planetmint server 0.7.0


0.0.1dev1 (2016-08-25)
----------------------

* Development (pre-alpha) release on PyPI.

Added
^^^^^
* Minimal support for ``POST`` (via ``create()`` and ``transfer()``), and
  ``GET`` operations on the ``/transactions`` endpoint.


0.0.1a1 (2016-08-12)
--------------------

* Planning release on PyPI.


