Mercurial > public > bitcaviar-plus
changeset 30:dbf757904681
CHnage info files
author | Dennis <dennis@denniscm.com> |
---|---|
date | Fri, 11 Aug 2023 16:36:36 +0000 |
parents | d9537541d623 |
children | 58692905e183 |
files | .github/ISSUE_TEMPLATE/bug_report.md .github/ISSUE_TEMPLATE/feature_request.md .github/workflows/python-publish.yml .idea/.gitignore .idea/bitcaviar-plus.iml .idea/inspectionProfiles/Project_Default.xml .idea/inspectionProfiles/profiles_settings.xml .idea/misc.xml .idea/modules.xml .idea/vcs.xml CHANGELOG.md DOCS.md LICENSE.md README.md |
diffstat | 14 files changed, 127 insertions(+), 288 deletions(-) [+] |
line wrap: on
line diff
--- a/.github/ISSUE_TEMPLATE/bug_report.md Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here.
--- a/.github/ISSUE_TEMPLATE/feature_request.md Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here.
--- a/.github/workflows/python-publish.yml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -name: Upload Python Package - -on: - push: - tags: [ '*.*.*' ] - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - python -m pip install flake8 - 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: Testing units - run: python -m unittest tests.test_unit - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }}
--- a/.idea/.gitignore Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Zeppelin ignored files -/ZeppelinRemoteNotebooks/
--- a/.idea/bitcaviar-plus.iml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="PYTHON_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> - <excludeFolder url="file://$MODULE_DIR$/venv" /> - <excludeFolder url="file://$MODULE_DIR$/tests/output_files" /> - <excludeFolder url="file://$MODULE_DIR$/.idea/ZeppelinRemoteNotebooks" /> - </content> - <orderEntry type="jdk" jdkName="Python 3.8 (bitcaviar-plus)" jdkType="Python SDK" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file
--- a/.idea/inspectionProfiles/Project_Default.xml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -<component name="InspectionProjectProfileManager"> - <profile version="1.0"> - <option name="myName" value="Project Default" /> - <inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> - <inspection_tool class="PyAugmentAssignmentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> - <inspection_tool class="PyBehaveInspection" enabled="true" level="WARNING" enabled_by_default="true" /> - <inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" /> - <inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true"> - <option name="ourVersions"> - <value> - <list size="2"> - <item index="0" class="java.lang.String" itemvalue="2.7" /> - <item index="1" class="java.lang.String" itemvalue="3.10" /> - </list> - </value> - </option> - </inspection_tool> - <inspection_tool class="PyMandatoryEncodingInspection" enabled="true" level="WARNING" enabled_by_default="true" /> - <inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" /> - <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true"> - <option name="ignoredPackages"> - <value> - <list size="1"> - <item index="0" class="java.lang.String" itemvalue="httpretty" /> - </list> - </value> - </option> - </inspection_tool> - <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true"> - <option name="ignoredIdentifiers"> - <list> - <option value="src.handlers.sentiment.secrets_controller" /> - <option value="flask.Flask" /> - </list> - </option> - </inspection_tool> - </profile> -</component> \ No newline at end of file
--- a/.idea/inspectionProfiles/profiles_settings.xml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -<component name="InspectionProjectProfileManager"> - <settings> - <option name="USE_PROJECT_PROFILE" value="false" /> - <version value="1.0" /> - </settings> -</component> \ No newline at end of file
--- a/.idea/misc.xml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (bitcaviar-plus)" project-jdk-type="Python SDK" /> -</project> \ No newline at end of file
--- a/.idea/modules.xml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/bitcaviar-plus.iml" filepath="$PROJECT_DIR$/.idea/bitcaviar-plus.iml" /> - </modules> - </component> -</project> \ No newline at end of file
--- a/.idea/vcs.xml Mon Aug 07 15:31:56 2023 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="GitSharedSettings"> - <option name="FORCE_PUSH_PROHIBITED_PATTERNS"> - <list> - <option value="main" /> - </list> - </option> - </component> - <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$" vcs="Git" /> - </component> -</project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CHANGELOG.md Fri Aug 11 16:36:36 2023 +0000 @@ -0,0 +1,10 @@ + +# Table of Contents + +1. [2021-10-26 -> 0.0.1](#org6fe2714) + + +<a id="org6fe2714"></a> + +# 2021-10-26 -> 0.0.1 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DOCS.md Fri Aug 11 16:36:36 2023 +0000 @@ -0,0 +1,106 @@ + +# Table of Contents + +1. [Installation](#org79ef3e8) +2. [Usage](#org47a2d85) + 1. [Example 1 -> Deserialize genesis block](#orgb8ccd7c) + 2. [Example 2 -> Deserialize entire blockchain](#org6c651d9) + + + + +<a id="org79ef3e8"></a> + +# Installation + +Recommended: + + pip install bitcaviar-plus + +Manual: + + python setup.py install + + +<a id="org47a2d85"></a> + +# Usage + + +<a id="orgb8ccd7c"></a> + +## Example 1 -> Deserialize genesis block + + from bitcaviar_plus.block import deserialize_block + + + def parse_genesis_block(): + with open('path/to/file/blk00000.dat', 'rb') as f: + block = deserialize_block(f) + print(block) + + +<a id="org6c651d9"></a> + +## Example 2 -> Deserialize entire blockchain + + import os + from bitcaviar_plus.block import deserialize_block + from bitcaviar_plus.errors import InvalidMagicBytes + + + def parse_entire_blockchain(): + file_counter = -1 + while True: + file_counter += 1 + file_name = 'path/to/file/blk{}.dat'.format(str(file_counter).zfill(5)) + with open(file_name, 'rb') as f: + file_size = os.path.getsize(file_name) + while f.tell() < file_size: + try: + block = deserialize_block(f) + except InvalidMagicBytes as e: + print(e) + +Example output: + + { + "magic_number":"f9beb4d9", + "size":"0000011d", + "id":"000000000019d6...", + "transaction_count":"01", + "header":{ + "version":"00000001", + "previous_block_id":"00000000000000...", + "merkle_root":"4a5e1e4baab89f3a32...", + "time":"495fab29", + "bits":"1d00ffff", + "nonce":"7c2bac1d" + }, + "transactions":[ + { + "version":"00000001", + "input_count":"01", + "output_count":"01", + "lock_time":"00000000", + "id":"4a5e1e4baab89f3a32518a8...", + "inputs":[ + { + "id":"0000000000000000000000...", + "vout":"ffffffff", + "script_sig_size":"4d", + "script_sig":"04ffff001d01044554686520546...", + "sequence":"ffffffff" + } + ], + "outputs":[ + { + "value":"000000012a05f200", + "script_pub_key_size":"43", + "script_pub_key":"4104678afdb0fe55482719..." + } + ] + } + ] + } +
--- a/LICENSE.md Mon Aug 07 15:31:56 2023 +0100 +++ b/LICENSE.md Fri Aug 11 16:36:36 2023 +0000 @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Dennis Concepción Martín +Copyright (c) 2023 Dennis Concepción Martín Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,3 +19,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +
--- a/README.md Mon Aug 07 15:31:56 2023 +0100 +++ b/README.md Fri Aug 11 16:36:36 2023 +0000 @@ -1,108 +1,18 @@ -<!--suppress HtmlDeprecatedAttribute, HtmlRequiredAltAttribute --> -<p align="center"> - <img src="https://user-images.githubusercontent.com/66180929/136657868-0ec6971b-ed76-43f3-9689-f643e8893706.png" /> -</p> - # bitcaviar-plus [DEPRECATED] A Bitcoin blockchain parser written in Python. -## Installation - -### Recommended - -```bash -pip install bitcaviar-plus -``` - -### Manual - -```bash -python setup.py install -``` - -## Usage - -### Deserialize Genesis block - -```python -from bitcaviar_plus.block import deserialize_block - - -def parse_genesis_block(): - with open('path/to/file/blk00000.dat', 'rb') as f: - block = deserialize_block(f) - print(block) -``` - -### Deserialize entire blockchain - -```python -import os -from bitcaviar_plus.block import deserialize_block -from bitcaviar_plus.errors import InvalidMagicBytes +- Docs: <https://denniscm.com/proj/bitcaviar-plus.html> +- Main repo on SourceHut: <https://git.sr.ht/~denniscmartin/bitcaviar-plus> + - Mirrors: + - Github: <https://github.com/denniscmartin/bitcaviar-plus> + - Gitlab: <https://gitlab.com/denniscmartin/bitcaviar-plus> -def parse_entire_blockchain(): - file_counter = -1 - while True: - file_counter += 1 - file_name = 'path/to/file/blk{}.dat'.format(str(file_counter).zfill(5)) - with open(file_name, 'rb') as f: - file_size = os.path.getsize(file_name) - while f.tell() < file_size: - try: - block = deserialize_block(f) - except InvalidMagicBytes as e: - print(e) -``` - -### Example output +## Attribution -```json -{ - "magic_number":"f9beb4d9", - "size":"0000011d", - "id":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", - "transaction_count":"01", - "header":{ - "version":"00000001", - "previous_block_id":"0000000000000000000000000000000000000000000000000000000000000000", - "merkle_root":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", - "time":"495fab29", - "bits":"1d00ffff", - "nonce":"7c2bac1d" - }, - "transactions":[ - { - "version":"00000001", - "input_count":"01", - "output_count":"01", - "lock_time":"00000000", - "id":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", - "inputs":[ - { - "id":"0000000000000000000000000000000000000000000000000000000000000000", - "vout":"ffffffff", - "script_sig_size":"4d", - "script_sig":"04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73", - "sequence":"ffffffff" - } - ], - "outputs":[ - { - "value":"000000012a05f200", - "script_pub_key_size":"43", - "script_pub_key":"4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" - } - ] - } - ] -} -``` +- [blockchain-parser](https://github.com/ragestack/blockchain-parser/blob/master/blockchain-parser.py) +- [bitcoinbook](https://github.com/bitcoinbook/bitcoinbook) +- [learnmeabitcoin.com](https://learnmeabitcoin.com/) -## Attribution -- [blockchain-parser](https://github.com/ragestack/blockchain-parser/blob/master/blockchain-parser.py) -- [bitcoinbook](https://github.com/bitcoinbook/bitcoinbook) -- [LearnMeABitcoin.com](https://learnmeabitcoin.com)