From dc3812d0b3244a9074e6d6b95d746cf6c0214a61 Mon Sep 17 00:00:00 2001
From: Holger <holger@nahrstaedt.de>
Date: Sat, 12 Jan 2019 12:13:24 +0100
Subject: [PATCH] Replace secp256k1 by secp256k1prp which is better maintained
 and available on more platforms

---
 .circleci/config.yml                   |  2 +-
 .travis.yml                            |  2 +-
 CHANGELOG.rst                          |  6 ++++++
 README.rst                             |  6 ++++++
 beemgraphenebase/ecdsasig.py           | 17 +++++++++++------
 beemgraphenebase/signedtransactions.py | 18 ++++++++++++------
 requirements-test.txt                  |  2 +-
 tox.ini                                |  4 ++--
 8 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 815de763..978aa795 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -35,7 +35,7 @@ jobs:
           name: install dependencies
           command: |
             sudo python -m pip install -r requirements-test.txt
-            sudo python -m pip install --upgrade secp256k1
+            sudo python -m pip install --upgrade secp256k1prp
 
       # run tests!
       # this example uses Django's built-in test-runner
diff --git a/.travis.yml b/.travis.yml
index a36a3e50..f04f18c9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -57,7 +57,7 @@ before_install:
   - pip install --upgrade pip
   - pip install --upgrade wheel
   # Set numpy version first, other packages link against it
-  - pip install six nose coverage codecov tox-travis pytest pytest-cov coveralls codacy-coverage parameterized secp256k1 cryptography scrypt
+  - pip install six nose coverage codecov tox-travis pytest pytest-cov coveralls codacy-coverage parameterized secp256k1prp cryptography scrypt
   - pip install pycryptodomex  pyyaml appdirs pylibscrypt
   - pip install ecdsa requests future websocket-client pytz six Click events prettytable
 
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index aafcb2e0..47871ec3 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,11 @@
 Changelog
 =========
+0.20.17
+-------
+* Fix transfer rounding error, which prevent transfering of e.g. 1.013 STEEM.
+* get_account_votes works again with api.steemit.com
+* Use secp256k1prp as better replacement for secp256k1
+
 0.20.16
 -------
 * Fix beempy walletinfo and sign
diff --git a/README.rst b/README.rst
index 05eb93b5..c26525a2 100644
--- a/README.rst
+++ b/README.rst
@@ -107,6 +107,12 @@ Signing and Verify can be fasten (200 %) by installing cryptography:
 
     pip install -U cryptography
 
+or:
+
+.. code:: bash
+
+    pip install -U secp256k1prp
+
 Install or update beem by pip::
 
     pip install -U beem
diff --git a/beemgraphenebase/ecdsasig.py b/beemgraphenebase/ecdsasig.py
index 151dcc9b..1e849f4e 100644
--- a/beemgraphenebase/ecdsasig.py
+++ b/beemgraphenebase/ecdsasig.py
@@ -22,16 +22,21 @@ CRYPTOGRAPHY_AVAILABLE = False
 GMPY2_MODULE = False
 if not SECP256K1_MODULE:
     try:
-        import secp256k1
+        import secp256k1prp as secp256k1
         SECP256K1_MODULE = "secp256k1"
         SECP256K1_AVAILABLE = True
-    except ImportError:
+    except:
         try:
-            import cryptography
-            SECP256K1_MODULE = "cryptography"
-            CRYPTOGRAPHY_AVAILABLE = True
+            import secp256k1
+            SECP256K1_MODULE = "secp256k1"
+            SECP256K1_AVAILABLE = True
         except ImportError:
-            SECP256K1_MODULE = "ecdsa"
+            try:
+                import cryptography
+                SECP256K1_MODULE = "cryptography"
+                CRYPTOGRAPHY_AVAILABLE = True
+            except ImportError:
+                SECP256K1_MODULE = "ecdsa"
 
     try:
         from cryptography.hazmat.backends import default_backend
diff --git a/beemgraphenebase/signedtransactions.py b/beemgraphenebase/signedtransactions.py
index cfec71d4..5e91fa05 100644
--- a/beemgraphenebase/signedtransactions.py
+++ b/beemgraphenebase/signedtransactions.py
@@ -26,13 +26,19 @@ import logging
 log = logging.getLogger(__name__)
 
 try:
-    import secp256k1
+    import secp256k1prp as secp256k1
     USE_SECP256K1 = True
-    log.debug("Loaded secp256k1 binding.")
-except Exception:
-    USE_SECP256K1 = False
-    log.debug("To speed up transactions signing install \n"
-              "    pip install secp256k1")
+    log.debug("Loaded secp256k1prp binding.")    
+except:
+    try:
+        import secp256k1
+        USE_SECP256K1 = True
+        log.debug("Loaded secp256k1 binding.")
+    except Exception:
+        USE_SECP256K1 = False
+        log.debug("To speed up transactions signing install \n"
+                  "    pip install secp256k1\n"
+                  "or  pip install secp256k1prp")
 
 
 class Signed_Transaction(GrapheneObject):
diff --git a/requirements-test.txt b/requirements-test.txt
index 5b250835..8fa8ef96 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -10,7 +10,7 @@ pycryptodomex==3.7.2
 scrypt==0.8.6
 Events==0.3
 cryptography==2.4.2
-pyyaml==3.13
+pyyaml>=4.2b1
 mock==2.0.0
 appdirs==1.4.3
 Click==7.0
diff --git a/tox.ini b/tox.ini
index 3baf4e42..5e8d759d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -22,7 +22,7 @@ deps =
     secp256k1
     scrypt
 commands =
-    coverage run --parallel-mode -m pytest tests/beem tests/beemapi tests/beembase tests/beemgraphene {posargs}
+    coverage run --parallel-mode -m pytest {posargs}
     coverage combine
     coverage report -m
     coverage xml
@@ -47,7 +47,7 @@ deps =
     secp256k1
     scrypt
 commands =
-    coverage run --parallel-mode -m pytest tests/beem tests/beemapi tests/beembase tests/beemgraphene {posargs}
+    coverage run --parallel-mode -m pytest {posargs}
     coverage combine
     coverage report -m
     coverage xml
-- 
GitLab