Merge branch 'master' into pynacl

pynacl
Michał Sałaban 2 years ago
commit 9c594e0692

@ -0,0 +1,8 @@
[bumpversion]
current_version = 0.9.3
[bumpversion:file:README.rst]
[bumpversion:file:monero/__init__.py]
[bumpversion:file:docs/source/conf.py]

1
.gitignore vendored

@ -3,6 +3,7 @@
!.gitignore
!.travis.yml
!.pre-commit-config.yaml
!.bumpversion.cfg
*.py[co]
*~
*.bak

@ -18,6 +18,7 @@ install:
- pip install dist/*.tar.gz # install dependencies as specified in setup.py
- pip install -r test_requirements_py`echo $TRAVIS_PYTHON_VERSION | cut -f 1 -d .`.txt
script:
- black --check .
- pytest
after_success:
- coveralls

@ -14,7 +14,7 @@ Python Monero module
A comprehensive Python module for handling Monero cryptocurrency.
* release 0.9.2
* release 0.9.3
* open source: https://github.com/monero-ecosystem/monero-python
* works with Monero 0.13.x and `the latest source`_ (at least we try to keep up)
* Python 2.x and 3.x compatible
@ -36,7 +36,8 @@ Released under the BSD 3-Clause License. See `LICENSE.txt`_.
Copyright (c) 2017-2018 Michał Sałaban <michal@salaban.info> and Contributors:
`lalanza808`_, `cryptochangements34`_, `atward`_, `rooterkyberian`_, `brucexiu`_,
`lialsoftlab`_, `moneroexamples`_, `massanchik`_, `MrClottom`_, `jeffro256`_.
`lialsoftlab`_, `moneroexamples`_, `massanchik`_, `MrClottom`_, `jeffro256`_,
`sometato`_.
Copyright (c) 2016 The MoneroPy Developers (``monero/base58.py`` taken from `MoneroPy`_)
@ -59,6 +60,7 @@ Copyright (c) 2011 thomasv@gitorious (``monero/seed.py`` based on `Electrum`_)
.. _`massanchik`: https://github.com/massanchik
.. _`MrClottom`: https://github.com/MrClottom
.. _`jeffro256`: https://github.com/jeffro256
.. _`sometato`: https://github.com/sometato
Want to help?
-------------
@ -91,3 +93,9 @@ Development
.. code-block:: bash
.venv/bin/pytest
6. Format your code with black
.. code-block:: bash
.venv/bin/black .

@ -3,8 +3,27 @@ Authors
* Michał Sałaban <michal@salaban.info>
* MoneroPy Developers (``monero/base58.py`` taken from `MoneroPy`_)
* `pyca/ed25519`_ Developers (``monero/ed25519.py``)
* thomasv@gitorious (``monero/seed.py`` based on `Electrum`_)
* and other Contributors: `lalanza808`_, `cryptochangements34`_, `atward`_, `rooterkyberian`_, `brucexiu`_, `lialsoftlab`_, `moneroexamples`_, `massanchik`_, `MrClottom`_, `jeffro256`_, `sometato`_.
.. _MoneroPy: https://github.com/bigreddmachine/MoneroPy
.. _`LICENSE.txt`: LICENSE.txt
.. _`MoneroPy`: https://github.com/bigreddmachine/MoneroPy
.. _`pyca/ed25519`: https://github.com/pyca/ed25519
.. _`Electrum`: https://github.com/spesmilo/electrum
.. _`lalanza808`: https://github.com/lalanza808
.. _`cryptochangements34`: https://github.com/cryptochangements34
.. _`atward`: https://github.com/atward
.. _`rooterkyberian`: https://github.com/rooterkyberian
.. _`brucexiu`: https://github.com/brucexiu
.. _`lialsoftlab`: https://github.com/lialsoftlab
.. _`moneroexamples`: https://github.com/moneroexamples
.. _`massanchik`: https://github.com/massanchik
.. _`MrClottom`: https://github.com/MrClottom
.. _`jeffro256`: https://github.com/jeffro256
.. _`sometato`: https://github.com/sometato
Acknowledgements
----------------

@ -56,9 +56,9 @@ author = "Michal Salaban"
# built documents.
#
# The short X.Y version.
version = "0.9.2"
version = "0.9.3"
# The full version, including alpha/beta/rc tags.
release = "0.9.2"
release = "0.9.3"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

@ -164,6 +164,7 @@ methods in JSONRPCDaemon are designed to be lower-level. As such, the return val
methods reflect the raw JSON objects returned by the daemon. An example:
.. code-block:: python
[In 20]: from monero.backends.jsonrpc import JSONRPCDaemon
[In 21]: daemon = JSONRPCDaemon(host='192.168.0.50')

@ -1,3 +1,3 @@
from . import address, account, const, daemon, wallet, numbers, wordlists, seed
__version__ = "0.9.2"
__version__ = "0.9.3"

@ -106,8 +106,8 @@ class JSONRPCDaemon(object):
protocol=protocol, host=host, port=port
)
_log.debug("JSONRPC daemon backend URL: {url}".format(url=self.url))
self.user = user
self.password = password
self.auth = requests.auth.HTTPDigestAuth(user, password)
self.session = requests.Session()
self.timeout = timeout
self.verify_ssl_certs = verify_ssl_certs
self.proxies = {protocol: proxy_url}
@ -222,12 +222,11 @@ class JSONRPCDaemon(object):
path=path, data=json.dumps(data, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
rsp = self.session.post(
self.url + path,
headers=hdr,
data=json.dumps(data) if data else None,
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,
@ -251,12 +250,11 @@ class JSONRPCDaemon(object):
method=method, params=json.dumps(params, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
rsp = self.session.post(
self.url + "/json_rpc",
headers=hdr,
data=json.dumps(data),
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,

@ -50,8 +50,8 @@ class JSONRPCWallet(object):
protocol=protocol, host=host, port=port
)
_log.debug("JSONRPC wallet backend URL: {url}".format(url=self.url))
self.user = user
self.password = password
self.auth = requests.auth.HTTPDigestAuth(user, password)
self.session = requests.Session()
self.timeout = timeout
self.verify_ssl_certs = verify_ssl_certs
self.proxies = {protocol: proxy_url}
@ -386,12 +386,11 @@ class JSONRPCWallet(object):
method=method, params=json.dumps(params, indent=2, sort_keys=True)
)
)
auth = requests.auth.HTTPDigestAuth(self.user, self.password)
rsp = requests.post(
rsp = self.session.post(
self.url,
headers=hdr,
data=json.dumps(data),
auth=auth,
auth=self.auth,
timeout=self.timeout,
verify=self.verify_ssl_certs,
proxies=self.proxies,

@ -1,3 +1,4 @@
black==21.11b1
coverage~=5.3
coveralls~=2.1
pip>=9

@ -1,6 +1,7 @@
from datetime import datetime
from decimal import Decimal
import responses
import requests
try:
from unittest.mock import patch, Mock
@ -50,7 +51,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
},
}
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_seed(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -70,7 +71,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(seed, Seed)
self.assertEqual(seed.phrase, phrase)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_balance(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -219,7 +220,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(subaddr, SubAddress)
self.assertIsInstance(index, int)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_incoming_confirmed(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -369,7 +370,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(pmt.transaction.fee, Decimal)
self.assertIsInstance(pmt.transaction.height, int)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_incoming_confirmed_and_unconfirmed(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -549,7 +550,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(pmt.transaction.fee, Decimal)
self.assertIsInstance(pmt.transaction.height, (int, type(None)))
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_incoming_unconfirmed(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -851,7 +852,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertEqual(pmts[0].amount, Decimal("0.52"))
self.assertEqual(pmts[1].amount, Decimal("0.0212"))
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_incoming_by_payment_ids(self, mock_post):
# These queries will use get_bulk_payments RPC method instead of get_transfers
mock_post.return_value.status_code = 200
@ -962,7 +963,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(pmt.transaction.height, int)
self.assertIn(pmt.payment_id, ids)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_outgoing(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1189,7 +1190,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(pmt.transaction.fee, Decimal)
self.assertIsInstance(pmt.transaction.height, int)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_outgoing_confirmed_and_unconfirmed(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1432,7 +1433,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(pmt.transaction.fee, Decimal)
self.assertIsInstance(pmt.transaction.height, (int, type(None)))
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_outgoing_unconfirmed_only(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1493,7 +1494,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertEqual(len(pmt.destinations), 2)
self.assertEqual(pmt.destinations[0][1] + pmt.destinations[1][1], pmt.amount)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_send_transfer(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1562,7 +1563,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
self.assertIsInstance(result[0], Transaction)
self.assertEqual(Decimal("111.086545699972"), result[1])
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_dynamic_ring_size_deprecation(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1587,7 +1588,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
},
}
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_export_import_outputs(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result
@ -1608,7 +1609,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
}
self.assertEqual(self.wallet.import_outputs(outs_hex), 9)
@patch("monero.backends.jsonrpc.wallet.requests.post")
@patch.object(requests.Session, "post")
def test_export_import_key_images(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = self.accounts_result

@ -9,7 +9,13 @@ from monero.daemon import Daemon
def url_data(url):
gs = re.compile(r"^(?P<host>[^:\s]+)(?::(?P<port>[0-9]+))?$").match(url).groupdict()
gs = (
re.compile(
r"^(?:(?P<user>[a-z0-9_-]+)?(?::(?P<password>[^@]+))?@)?(?P<host>[^:\s]+)(?::(?P<port>[0-9]+))?$"
)
.match(url)
.groupdict()
)
return dict(filter(operator.itemgetter(1), gs.items()))
@ -20,7 +26,7 @@ def get_daemon():
nargs="?",
type=url_data,
default="127.0.0.1:18081",
help="Daemon RPC URL [host[:port]]",
help="Daemon RPC URL [user[:password]@]host[:port]",
)
argsparser.add_argument(
"-p", dest="proxy_url", nargs="?", type=str, default=None, help="Proxy URL"

Loading…
Cancel
Save