diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..14a4e65 --- /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.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 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..ff333df 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.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 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' ] ) 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