From 9428726cecc49ad5faa38743c139428c31018ab8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:25:05 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- btclib/psbt/psbt_in.py | 33 +++++++++++++++++++-------------- btclib/psbt/psbt_out.py | 5 +++-- btclib/tx/tx.py | 13 ++++++++----- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/btclib/psbt/psbt_in.py b/btclib/psbt/psbt_in.py index 1f12a0bf..5159210e 100644 --- a/btclib/psbt/psbt_in.py +++ b/btclib/psbt/psbt_in.py @@ -200,8 +200,9 @@ def __init__( taproot_key_spend_signature: Octets = b"", taproot_script_spend_signatures: Mapping[Octets, Octets] | None = None, taproot_leaf_scripts: Mapping[Octets, tuple[Octets, int]] | None = None, - taproot_hd_key_paths: Mapping[Octets, tuple[list[Octets], BIP32KeyOrigin]] - | None = None, + taproot_hd_key_paths: ( + Mapping[Octets, tuple[list[Octets], BIP32KeyOrigin]] | None + ) = None, taproot_internal_key: Octets = b"", taproot_merkle_root: Octets = b"", unknown: Mapping[Octets, Octets] | None = None, @@ -283,12 +284,12 @@ def to_dict(self, check_validity: bool = True) -> dict[str, Any]: self.assert_valid() return { - "non_witness_utxo": self.non_witness_utxo.to_dict(False) - if self.non_witness_utxo - else None, - "witness_utxo": self.witness_utxo.to_dict(False) - if self.witness_utxo - else None, + "non_witness_utxo": ( + self.non_witness_utxo.to_dict(False) if self.non_witness_utxo else None + ), + "witness_utxo": ( + self.witness_utxo.to_dict(False) if self.witness_utxo else None + ), "partial_signatures": encode_dict_bytes_bytes(self.partial_sigs), "sig_hash": self.sig_hash_type, # TODO make it { "asm": "", "hex": "" } @@ -327,12 +328,16 @@ def from_dict( decode_from_bip32_derivs(dict_["taproot_hd_key_paths"]), ) return cls( - Tx.from_dict(dict_["non_witness_utxo"], False) - if dict_["non_witness_utxo"] - else None, - TxOut.from_dict(dict_["witness_utxo"], False) - if dict_["witness_utxo"] - else None, + ( + Tx.from_dict(dict_["non_witness_utxo"], False) + if dict_["non_witness_utxo"] + else None + ), + ( + TxOut.from_dict(dict_["witness_utxo"], False) + if dict_["witness_utxo"] + else None + ), dict_["partial_signatures"], dict_["sig_hash"], dict_["redeem_script"], diff --git a/btclib/psbt/psbt_out.py b/btclib/psbt/psbt_out.py index f09bb5fe..2610e568 100644 --- a/btclib/psbt/psbt_out.py +++ b/btclib/psbt/psbt_out.py @@ -80,8 +80,9 @@ def __init__( hd_key_paths: Mapping[Octets, BIP32KeyOrigin] | None = None, taproot_internal_key: Octets = b"", taproot_tree: Sequence[tuple[int, int, Octets]] | None = None, - taproot_hd_key_paths: Mapping[Octets, tuple[list[bytes], BIP32KeyOrigin]] - | None = None, + taproot_hd_key_paths: ( + Mapping[Octets, tuple[list[bytes], BIP32KeyOrigin]] | None + ) = None, unknown: Mapping[Octets, Octets] | None = None, check_validity: bool = True, ) -> None: diff --git a/btclib/tx/tx.py b/btclib/tx/tx.py index 58da44ac..9b937dfc 100644 --- a/btclib/tx/tx.py +++ b/btclib/tx/tx.py @@ -224,11 +224,14 @@ def serialize(self, include_witness: bool, check_validity: bool = True) -> bytes b"".join(tx_in.serialize(check_validity) for tx_in in self.vin), var_int.serialize(len(self.vout)), b"".join(tx_out.serialize(check_validity) for tx_out in self.vout), - b"".join( - tx_in.script_witness.serialize(check_validity) for tx_in in self.vin - ) - if segwit - else b"", + ( + b"".join( + tx_in.script_witness.serialize(check_validity) + for tx_in in self.vin + ) + if segwit + else b"" + ), self.lock_time.to_bytes(4, byteorder="little", signed=False), ] )