btclib-org / btclib

btclib: a python3 library for 'bitcoin cryptography'
https://btclib.org
MIT License
97 stars 42 forks source link

tested Python 3.11, fixed OpenSSL 3.x issue, and more #78

Closed fametrano closed 1 year ago

fametrano commented 1 year ago

I was unaware of @giacomocaironi PR https://github.com/btclib-org/btclib/pull/75 and basically reimplemented it. I advocate for the approval of this PR as it also

The (test) bug fix in tests/tx/test_tx.py and the support of python 3.11 are also included.

I advocate for this to be our end-of-year release.

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.01%.

Quality metrics Before After Change
Complexity 4.30 ⭐ 4.29 ⭐ -0.01 👍
Method Length 94.66 🙂 94.61 🙂 -0.05 👍
Working memory 8.66 🙂 8.66 🙂 0.00
Quality 64.73% 🙂 64.74% 🙂 0.01% 👍
Other metrics Before After Change
Lines 18987 18991 4
Changed files Quality Before Quality After Quality Change
setup.py 75.34% ⭐ 75.22% ⭐ -0.12% 👎
btclib/__init__.py 98.17% ⭐ 98.17% ⭐ 0.00%
btclib/alias.py 76.12% ⭐ 76.12% ⭐ 0.00%
btclib/amount.py 86.86% ⭐ 86.86% ⭐ 0.00%
btclib/b32.py 72.64% 🙂 72.64% 🙂 0.00%
btclib/b58.py 85.03% ⭐ 85.03% ⭐ 0.00%
btclib/base58.py 77.28% ⭐ 77.28% ⭐ 0.00%
btclib/bech32.py 75.64% ⭐ 75.64% ⭐ 0.00%
btclib/exceptions.py 99.33% ⭐ 99.33% ⭐ 0.00%
btclib/hashes.py 87.07% ⭐ 86.27% ⭐ -0.80% 👎
btclib/network.py 73.19% 🙂 73.19% 🙂 0.00%
btclib/to_prv_key.py 59.09% 🙂 59.09% 🙂 0.00%
btclib/to_pub_key.py 67.49% 🙂 67.49% 🙂 0.00%
btclib/utils.py 82.03% ⭐ 82.03% ⭐ 0.00%
btclib/var_bytes.py 89.11% ⭐ 89.11% ⭐ 0.00%
btclib/var_int.py 79.56% ⭐ 79.56% ⭐ 0.00%
btclib/bip32/__init__.py % % %
btclib/bip32/bip32.py 61.34% 🙂 61.34% 🙂 0.00%
btclib/bip32/der_path.py 80.16% ⭐ 80.11% ⭐ -0.05% 👎
btclib/bip32/key_origin.py 88.53% ⭐ 88.53% ⭐ 0.00%
btclib/bip32/slip132.py 82.22% ⭐ 82.22% ⭐ 0.00%
btclib/ecc/__init__.py % % %
btclib/ecc/bms.py 62.98% 🙂 62.98% 🙂 0.00%
btclib/ecc/borromean.py 40.56% 😞 40.56% 😞 0.00%
btclib/ecc/curve.py 59.82% 🙂 59.82% 🙂 0.00%
btclib/ecc/curve_group.py 68.29% 🙂 68.29% 🙂 0.00%
btclib/ecc/curve_group_2.py 47.99% 😞 47.99% 😞 0.00%
btclib/ecc/curve_group_f.py 77.64% ⭐ 77.64% ⭐ 0.00%
btclib/ecc/der.py 71.88% 🙂 71.88% 🙂 0.00%
btclib/ecc/dh.py 67.59% 🙂 67.59% 🙂 0.00%
btclib/ecc/dsa.py 64.55% 🙂 64.55% 🙂 0.00%
btclib/ecc/libsecp256k1.py 96.02% ⭐ 96.02% ⭐ 0.00%
btclib/ecc/number_theory.py 59.06% 🙂 59.06% 🙂 0.00%
btclib/ecc/pedersen.py 81.79% ⭐ 81.79% ⭐ 0.00%
btclib/ecc/rfc6979.py 57.55% 🙂 57.55% 🙂 0.00%
btclib/ecc/sec_point.py 46.93% 😞 46.93% 😞 0.00%
btclib/ecc/sign_to_contract.py 74.67% 🙂 74.67% 🙂 0.00%
btclib/ecc/ssa.py 66.86% 🙂 66.86% 🙂 0.00%
btclib/mnemonic/__init__.py % % %
btclib/mnemonic/bip39.py 81.43% ⭐ 81.43% ⭐ 0.00%
btclib/mnemonic/electrum.py 74.48% 🙂 74.48% 🙂 0.00%
btclib/mnemonic/entropy.py 62.82% 🙂 62.82% 🙂 0.00%
btclib/mnemonic/mnemonic.py 76.85% ⭐ 76.85% ⭐ 0.00%
btclib/psbt/__init__.py % % %
btclib/psbt/psbt.py 60.47% 🙂 60.47% 🙂 0.00%
btclib/psbt/psbt_in.py 57.31% 🙂 57.36% 🙂 0.05% 👍
btclib/psbt/psbt_out.py 75.62% ⭐ 75.62% ⭐ 0.00%
btclib/psbt/psbt_utils.py 82.76% ⭐ 82.76% ⭐ 0.00%
btclib/script/__init__.py % % %
btclib/script/script.py 64.74% 🙂 64.74% 🙂 0.00%
btclib/script/script_pub_key.py 77.92% ⭐ 77.92% ⭐ 0.00%
btclib/script/sig_hash.py 44.35% 😞 44.39% 😞 0.04% 👍
btclib/script/taproot.py 61.72% 🙂 61.72% 🙂 0.00%
btclib/script/witness.py 87.89% ⭐ 87.89% ⭐ 0.00%
btclib/tx/__init__.py % % %
btclib/tx/block_header.py 74.31% 🙂 74.31% 🙂 0.00%
btclib/tx/blocks.py 84.93% ⭐ 84.93% ⭐ 0.00%
btclib/tx/out_point.py 86.70% ⭐ 86.70% ⭐ 0.00%
btclib/tx/tx.py 80.89% ⭐ 80.89% ⭐ 0.00%
btclib/tx/tx_in.py 88.00% ⭐ 88.00% ⭐ 0.00%
btclib/tx/tx_out.py 88.61% ⭐ 88.61% ⭐ 0.00%
docs/source/conf.py 89.18% ⭐ 89.18% ⭐ 0.00%
tests/test_amount.py 78.45% ⭐ 78.45% ⭐ 0.00%
tests/test_b32.py 80.10% ⭐ 80.10% ⭐ 0.00%
tests/test_b58.py 69.42% 🙂 69.42% 🙂 0.00%
tests/test_base58.py 85.72% ⭐ 85.72% ⭐ 0.00%
tests/test_bech32.py 74.10% 🙂 74.10% 🙂 0.00%
tests/test_hashes.py 93.90% ⭐ 93.90% ⭐ 0.00%
tests/test_network.py 87.70% ⭐ 87.70% ⭐ 0.00%
tests/test_to_key.py 28.04% 😞 28.04% 😞 0.00%
tests/test_to_prv_key.py 47.54% 😞 47.54% 😞 0.00%
tests/test_to_pub_key.py 43.25% 😞 43.25% 😞 0.00%
tests/test_utils.py 80.16% ⭐ 80.16% ⭐ 0.00%
tests/test_var_int.py 68.74% 🙂 68.74% 🙂 0.00%
tests/bip32/__init__.py % % %
tests/bip32/test_bip32.py 66.69% 🙂 66.69% 🙂 0.00%
tests/bip32/test_der_path.py 73.75% 🙂 73.75% 🙂 0.00%
tests/bip32/test_key_origin.py 68.85% 🙂 68.85% 🙂 0.00%
tests/bip32/test_slip132.py 56.70% 🙂 56.70% 🙂 0.00%
tests/ecc/__init__.py % % %
tests/ecc/test_bms.py 55.01% 🙂 55.01% 🙂 0.00%
tests/ecc/test_borromean.py 60.07% 🙂 60.07% 🙂 0.00%
tests/ecc/test_curve.py 60.81% 🙂 60.81% 🙂 0.00%
tests/ecc/test_curve_group.py 61.85% 🙂 61.85% 🙂 0.00%
tests/ecc/test_curve_group_2.py 65.21% 🙂 65.21% 🙂 0.00%
tests/ecc/test_curve_group_f.py 70.88% 🙂 70.88% 🙂 0.00%
tests/ecc/test_der.py 62.88% 🙂 62.88% 🙂 0.00%
tests/ecc/test_dh.py 57.09% 🙂 57.09% 🙂 0.00%
tests/ecc/test_dsa.py 55.40% 🙂 55.40% 🙂 0.00%
tests/ecc/test_number_theory.py 70.31% 🙂 70.31% 🙂 0.00%
tests/ecc/test_pedersen.py 75.05% ⭐ 75.05% ⭐ 0.00%
tests/ecc/test_rfc6979.py 63.41% 🙂 63.41% 🙂 0.00%
tests/ecc/test_sec_point.py 60.02% 🙂 60.02% 🙂 0.00%
tests/ecc/test_sign_to_contract.py 62.50% 🙂 62.50% 🙂 0.00%
tests/ecc/test_ssa.py 30.34% 😞 30.34% 😞 0.00%
tests/mnemonic/__init__.py % % %
tests/mnemonic/test_bip39.py 76.78% ⭐ 76.78% ⭐ 0.00%
tests/mnemonic/test_electrum.py 67.02% 🙂 67.02% 🙂 0.00%
tests/mnemonic/test_entropy.py 62.81% 🙂 62.81% 🙂 0.00%
tests/mnemonic/test_mnemonic.py 84.40% ⭐ 84.40% ⭐ 0.00%
tests/psbt/__init__.py % % %
tests/psbt/test_psbt.py 73.99% 🙂 73.99% 🙂 0.00%
tests/psbt/test_psbt_in.py 80.73% ⭐ 80.73% ⭐ 0.00%
tests/psbt/test_psbt_out.py 77.52% ⭐ 77.52% ⭐ 0.00%
tests/psbt/test_psbt_utils.py 98.63% ⭐ 98.63% ⭐ 0.00%
tests/script/__init__.py % % %
tests/script/test_script.py 83.21% ⭐ 83.21% ⭐ 0.00%
tests/script/test_script_pub_key.py 69.32% 🙂 69.32% 🙂 0.00%
tests/script/test_sig_hash_legacy.py 73.66% 🙂 73.66% 🙂 0.00%
tests/script/test_sig_hash_segwitv0.py 74.40% 🙂 74.40% 🙂 0.00%
tests/script/test_sig_hash_taproot.py 56.57% 🙂 56.57% 🙂 0.00%
tests/script/test_taproot.py 75.20% ⭐ 75.21% ⭐ 0.01% 👍
tests/script/test_witness.py 76.88% ⭐ 76.88% ⭐ 0.00%
tests/tx/__init__.py % % %
tests/tx/test_blocks.py 65.56% 🙂 65.56% 🙂 0.00%
tests/tx/test_out_point.py 76.52% ⭐ 76.53% ⭐ 0.01% 👍
tests/tx/test_tx.py 60.26% 🙂 60.25% 🙂 -0.01% 👎
tests/tx/test_tx_in.py 59.55% 🙂 59.55% 🙂 0.00%
tests/tx/test_tx_out.py 77.61% ⭐ 77.59% ⭐ -0.02% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tests/ecc/test_ssa.py test_threshold 33 ⛔ 1891 ⛔ 33 ⛔ 8.63% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/ecc/borromean.py sign 18 🙂 361 ⛔ 20 ⛔ 22.96% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/psbt/psbt_in.py PsbtIn.parse 16 🙂 280 ⛔ 32 ⛔ 23.29% ⛔ Try splitting into smaller methods. Extract out complex expressions
btclib/ecc/curve_group_2.py mult_sliding_window 29 😞 226 ⛔ 15 😞 25.37% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
btclib/script/sig_hash.py taproot 13 🙂 317 ⛔ 18 ⛔ 29.46% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!