Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 20, 2024
1 parent 1aa44a8 commit 34e6e57
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
33 changes: 19 additions & 14 deletions btclib/psbt/psbt_in.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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": "" }
Expand Down Expand Up @@ -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"],
Expand Down
5 changes: 3 additions & 2 deletions btclib/psbt/psbt_out.py
Expand Up @@ -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:
Expand Down
13 changes: 8 additions & 5 deletions btclib/tx/tx.py
Expand Up @@ -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),
]
)
Expand Down

0 comments on commit 34e6e57

Please sign in to comment.