Skip to content

Commit 92e1c3d

Browse files
forced libsecp256k1 and assorted minor fixes (#99)
--------- Co-authored-by: Giacomo Caironi <giacomo.caironi@gmail.com>
1 parent ebdb51e commit 92e1c3d

23 files changed

+19
-68
lines changed

.pre-commit-config.yaml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,8 @@ repos:
3939
- id: copyright-notice
4040
args: [--notice=COPYRIGHT]
4141
files: python
42-
- repo: https://github.com/asottile/pyupgrade
43-
rev: v3.3.1
44-
hooks:
45-
- id: pyupgrade
46-
args: [--py37-plus]
47-
# exclude: *fixtures
48-
language: python
49-
types: [python]
5042
- repo: https://github.com/PyCQA/autoflake
51-
rev: v2.0.0
43+
rev: v2.0.1
5244
hooks:
5345
- id: autoflake
5446
args:
@@ -61,8 +53,16 @@ repos:
6153
- --remove-rhs-for-unused-variables
6254
language: python
6355
types: [python]
56+
- repo: https://github.com/asottile/pyupgrade
57+
rev: v3.3.1
58+
hooks:
59+
- id: pyupgrade
60+
args: [--py37-plus]
61+
# exclude: *fixtures
62+
language: python
63+
types: [python]
6464
- repo: https://github.com/pycqa/isort
65-
rev: 5.11.4
65+
rev: 5.12.0
6666
hooks:
6767
- id: isort
6868
name: isort (black profile, in place fixes)
@@ -96,8 +96,14 @@ repos:
9696
- id: yesqa
9797
language: python
9898
types: [python]
99+
- repo: https://github.com/PyCQA/flake8
100+
rev: 6.0.0
101+
hooks:
102+
- id: flake8
103+
language: python
104+
types: [python]
99105
- repo: https://github.com/psf/black
100-
rev: 22.12.0
106+
rev: 23.1.0
101107
hooks:
102108
- id: black
103109
name: black (in place fixes)
@@ -109,12 +115,6 @@ repos:
109115
# language_version: python3.11
110116
language: python
111117
types: [python]
112-
- repo: https://github.com/PyCQA/flake8
113-
rev: 6.0.0
114-
hooks:
115-
- id: flake8
116-
language: python
117-
types: [python]
118118
- repo: https://github.com/PyCQA/bandit
119119
rev: 1.7.4
120120
hooks:
@@ -142,7 +142,6 @@ repos:
142142
hooks:
143143
- id: pylint
144144
args: [
145-
"--score=false",
146145
"--disable=E0401", # import-error
147146
]
148147
language: python

btclib/bip32/bip32.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ def __init__(
299299
key: Octets,
300300
check_validity: bool = True,
301301
) -> None:
302-
303302
super().__init__(
304303
version, depth, parent_fingerprint, index, chain_code, key, False
305304
)

btclib/block/block.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def __init__(
7575
transactions: Sequence[Tx] | None = None,
7676
check_validity: bool = True,
7777
) -> None:
78-
7978
self.header = header
8079

8180
# https://docs.python.org/3/tutorial/controlflow.html#default-argument-values
@@ -97,7 +96,6 @@ def to_dict(self, check_validity: bool = True) -> dict[str, Any]:
9796
def from_dict(
9897
cls: type[Block], dict_: Mapping[str, Any], check_validity: bool = True
9998
) -> Block:
100-
10199
return cls(
102100
BlockHeader.from_dict(dict_["header"], False),
103101
[Tx.from_dict(tx, False) for tx in dict_["transactions"]],

btclib/block/block_header.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def __init__(
104104
nonce: int = 0,
105105
check_validity: bool = True,
106106
) -> None:
107-
108107
self.version = version
109108
self.previous_block_hash = bytes_from_octets(previous_block_hash)
110109
self.merkle_root = bytes_from_octets(merkle_root_)
@@ -134,7 +133,6 @@ def to_dict(self, check_validity: bool = True) -> dict[str, int | float | str]:
134133
def from_dict(
135134
cls: type[BlockHeader], dict_: Mapping[str, Any], check_validity: bool = True
136135
) -> BlockHeader:
137-
138136
return cls(
139137
dict_["version"],
140138
dict_["previous_block_hash"],

btclib/ecc/dsa.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ def crack_prv_key_(
556556
sig2: Sig | Octets,
557557
hf: HashF = sha256,
558558
) -> tuple[int, int]:
559-
560559
if isinstance(sig1, Sig):
561560
sig1.assert_valid()
562561
else:
@@ -590,7 +589,6 @@ def crack_prv_key(
590589
sig2: Sig | Octets,
591590
hf: HashF = sha256,
592591
) -> tuple[int, int]:
593-
594592
msg_hash1 = reduce_to_hlen(msg1, hf)
595593
msg_hash2 = reduce_to_hlen(msg2, hf)
596594

btclib/ecc/rfc6979_nonce.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
def challenge_(
5252
msg_hash: Octets, ec: Curve = secp256k1, hf: HashF = hashlib.sha256
5353
) -> int:
54-
5554
# the message msg_hash: a hf_len array
5655
hf_len = hf().digest_size
5756
msg_hash = bytes_from_octets(msg_hash, hf_len)

btclib/mnemonic/entropy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ def bin_str_entropy_from_rolls(
303303
min_roll_number = math.ceil(bits / bits_per_roll)
304304
i = 0
305305
for roll in rolls:
306-
307306
# reject invalid rolls not in [1-dice_sides]
308307
if not 0 < roll <= dice_sides:
309308
msg = f"invalid roll: {roll} is not in [1-{dice_sides}]"

btclib/network.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def __init__(
101101
slip132_p2wsh_p2sh_pub: Octets,
102102
check_validity: bool = True,
103103
) -> None:
104-
105104
object.__setattr__(self, "curve", curve)
106105
object.__setattr__(self, "magic_bytes", bytes_from_octets(magic_bytes))
107106
object.__setattr__(self, "genesis_block", bytes_from_octets(genesis_block))
@@ -175,7 +174,6 @@ def to_dict(self, check_validity: bool = True) -> dict[str, str | None]:
175174
def from_dict(
176175
cls: type[Network], dict_: Mapping[str, Any], check_validity: bool = True
177176
) -> Network:
178-
179177
return cls(
180178
CURVES[dict_["curve"]],
181179
dict_["magic_bytes"],

btclib/psbt/psbt.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ def assert_signable(self) -> None:
143143
self.assert_valid()
144144

145145
for i, tx_in in enumerate(self.tx.vin):
146-
147146
non_witness_utxo = self.inputs[i].non_witness_utxo
148147
redeem_script = self.inputs[i].redeem_script
149148
# with python>=3.8 use walrus operator
@@ -191,7 +190,6 @@ def to_dict(self, check_validity: bool = True) -> dict[str, Any]:
191190
def from_dict(
192191
cls: type[Psbt], dict_: Mapping[str, Any], check_validity: bool = True
193192
) -> Psbt:
194-
195193
return cls(
196194
Tx.from_dict(dict_["tx"]),
197195
[PsbtIn.from_dict(psbt_in, False) for psbt_in in dict_["inputs"]],
@@ -284,7 +282,6 @@ def b64encode(self, check_validity: bool = True) -> str:
284282
def b64decode(
285283
cls: type[Psbt], psbt_str: String, check_validity: bool = True
286284
) -> Psbt:
287-
288285
if isinstance(psbt_str, str):
289286
psbt_str = psbt_str.strip()
290287

@@ -366,7 +363,6 @@ def combine_psbts(psbts: Sequence[Psbt]) -> Psbt:
366363

367364
final_psbt.version = max(psbt.version for psbt in psbts)
368365
for psbt in psbts[1:]:
369-
370366
for i, inp in enumerate(final_psbt.inputs):
371367
_combine_field(psbt.inputs[i], inp, "non_witness_utxo")
372368
_combine_field(psbt.inputs[i], inp, "witness_utxo")

btclib/psbt/psbt_in.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def to_dict(self, check_validity: bool = True) -> dict[str, Any]:
252252
def from_dict(
253253
cls: type[PsbtIn], dict_: Mapping[str, Any], check_validity: bool = True
254254
) -> PsbtIn:
255-
256255
return cls(
257256
Tx.from_dict(dict_["non_witness_utxo"], False)
258257
if dict_["non_witness_utxo"]
@@ -292,7 +291,6 @@ def serialize(self, check_validity: bool = True) -> bytes:
292291
)
293292

294293
if not self.final_script_sig and not self.final_script_witness:
295-
296294
if self.partial_sigs:
297295
psbt_in_bin.append(
298296
serialize_dict_bytes_bytes(PSBT_IN_PARTIAL_SIG, self.partial_sigs)

0 commit comments

Comments
 (0)