From a1ba6083dc2e1724e3e5d5ad04952d172e975fab Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 14:57:07 +0100 Subject: [PATCH 1/7] Use Github actions to build package --- .github/workflows/python-package.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..558b312 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.6", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From ef092ac9f074a7b26ba72e4f840f12a44e0e96b9 Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:09:40 +0100 Subject: [PATCH 2/7] Use ripemd-hash instead of hashlib for ripemd160 --- blockchain_parser/utils.py | 5 ++++- requirements.txt | 3 ++- setup.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/blockchain_parser/utils.py b/blockchain_parser/utils.py index fd04a89..407b9b2 100644 --- a/blockchain_parser/utils.py +++ b/blockchain_parser/utils.py @@ -12,10 +12,13 @@ import hashlib import struct +from ripemd import ripemd160 def btc_ripemd160(data): + """Computes ripemd160(sha256(data))""" + h1 = hashlib.sha256(data).digest() - r160 = hashlib.new("ripemd160") + r160 = ripemd160.new() r160.update(h1) return r160.digest() diff --git a/requirements.txt b/requirements.txt index 62477e9..c751a70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ python-bitcoinlib==0.11.0 plyvel==1.5.1 -coverage==7.4.4 \ No newline at end of file +ripemd-hash==1.0.1 +coverage==7.4.4 diff --git a/setup.py b/setup.py index 4f9bd63..214e177 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ ], install_requires=[ 'python-bitcoinlib==0.11.0', - 'plyvel==1.5.1' + 'plyvel==1.5.1', + 'ripemd-hash==1.0.1' ] ) From a010e1e1275699ca859e5c1f391b03a1f4e06d6d Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:11:18 +0100 Subject: [PATCH 3/7] Build on specific 3.6 python version --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 558b312..cc52e7e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.9", "3.10", "3.11"] + python-version: ["3.6.15", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 From 51b6b50e10be79afa1340d654bceda8265fca107 Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:13:10 +0100 Subject: [PATCH 4/7] Skip building on python 3.6 --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index cc52e7e..14a4e65 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6.15", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 From 2b4ef10dc17f2a08823b464643457fd1dc72ef02 Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:16:55 +0100 Subject: [PATCH 5/7] Remove Travis CI references --- .travis.yml | 22 ---------------------- README.md | 2 +- travis.sh | 17 ----------------- 3 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 .travis.yml delete mode 100755 travis.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 34f2a4c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -sudo: required - -language: - - python - -python: - - "3.6" - -before_install: - - ./travis.sh - -install: - - pip install -r requirements.txt - - pip install coveralls - -script: - - coverage run --append --include='blockchain_parser/*' --omit='*/tests/*' setup.py test - -after_success: - - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then - coveralls; - fi diff --git a/README.md b/README.md index 5af109c..4d70857 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bitcoin-blockchain-parser [![Build Status](https://travis-ci.org/alecalve/python-bitcoin-blockchain-parser.svg?branch=master)](https://travis-ci.org/alecalve/python-bitcoin-blockchain-parser) [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) +# bitcoin-blockchain-parser [![Build Status](https://github.com/alecalve/python-bitcoin-blockchain-parser/actions/workflows/python-package/badge.svg)] [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) This Python 3 library provides a parser for the raw data stored by bitcoind. ## Features diff --git a/travis.sh b/travis.sh deleted file mode 100755 index c1f0dca..0000000 --- a/travis.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# based on https://github.com/wbolster/plyvel/blob/fa460e431982e94034fe226faef570ce498c89ac/travis.sh -set -e -u -x - -LEVELDB_VERSION=1.20 - -wget https://github.com/google/leveldb/archive/v${LEVELDB_VERSION}.tar.gz -tar xf v${LEVELDB_VERSION}.tar.gz -cd leveldb-${LEVELDB_VERSION}/ -make - -# based on https://gist.github.com/dustismo/6203329 -sudo scp -r out-static/lib* out-shared/lib* /usr/local/lib/ -cd include/ -sudo scp -r leveldb /usr/local/include/ -sudo ldconfig From fe1c1799989556b555c6af71ef1104f70b025721 Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:19:32 +0100 Subject: [PATCH 6/7] Fix badge URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d70857..e71784c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bitcoin-blockchain-parser [![Build Status](https://github.com/alecalve/python-bitcoin-blockchain-parser/actions/workflows/python-package/badge.svg)] [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) +# bitcoin-blockchain-parser [![Build Status](https://github.com/alecalve/python-bitcoin-blockchain-parser/actions/workflows/python-package.yml/badge.svg)] [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) This Python 3 library provides a parser for the raw data stored by bitcoind. ## Features From 890e6d7724e03419cd45a27f069e2e147079def2 Mon Sep 17 00:00:00 2001 From: Antoine Le Calvez Date: Sat, 23 Mar 2024 15:21:18 +0100 Subject: [PATCH 7/7] Remove brackets --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e71784c..ff333df 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bitcoin-blockchain-parser [![Build Status](https://github.com/alecalve/python-bitcoin-blockchain-parser/actions/workflows/python-package.yml/badge.svg)] [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) +# bitcoin-blockchain-parser ![Build Status](https://github.com/alecalve/python-bitcoin-blockchain-parser/actions/workflows/python-package.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master) This Python 3 library provides a parser for the raw data stored by bitcoind. ## Features