Skip to content

Commit ad850fe

Browse files
Update version (#110)
* Fix circular import * Update version * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 57c2516 commit ad850fe

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

HISTORY.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ Notable changes to the codebase are documented here.
55
Release names follow *[calendar versioning](https://calver.org/)*:
66
full year, short month, short day (YYYY-M-D)
77

8-
## v2023.3 (work in progress, not released yet)
8+
## v2023.6 (work in progress, not released yet)
99

1010
Major changes include:
1111

1212
- TBD
1313

14+
## v2023.5.30
15+
16+
Major changes include:
17+
18+
- Fix circular import between ``script`` and ``b32``
19+
1420
## v2023.2.3
1521

1622
Major changes include:

btclib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""__init__ module for the btclib package."""
1212

1313
name = "btclib"
14-
__version__ = "2023.3"
14+
__version__ = "2023.5.30"
1515
__author__ = "The btclib developers"
1616
__author_email__ = "devs@btclib.org"
1717
__copyright__ = "Copyright (C) 2017-2023 The btclib developers"

btclib/b32.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@
4646

4747
from typing import Iterable
4848

49-
from btclib.alias import Octets, String, TaprootScriptTree
49+
from btclib.alias import Octets, String
5050
from btclib.bech32 import decode, encode
5151
from btclib.exceptions import BTClibValueError
5252
from btclib.hashes import hash160, sha256
5353
from btclib.network import NETWORKS, network_from_key_value
54-
from btclib.script import output_pubkey
5554
from btclib.to_pub_key import Key, pub_keyinfo_from_key
5655
from btclib.utils import bytes_from_octets
5756

@@ -170,11 +169,6 @@ def p2wsh(script_pub_key: Octets, network: str = "mainnet") -> str:
170169
return address_from_witness(0, h256, network)
171170

172171

173-
def p2tr(
174-
internal_key: Key | None = None,
175-
script_path: TaprootScriptTree | None = None,
176-
network: str = "mainnet",
177-
) -> str:
172+
def p2tr(output_key: Octets, network: str = "mainnet") -> str:
178173
"""Return the p2tr bech32 address corresponding to a taproot output key."""
179-
pub_key = output_pubkey(internal_key, script_path)[0]
180-
return address_from_witness(1, pub_key, network)
174+
return address_from_witness(1, output_key, network)

btclib/script/__init__.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,7 @@
1111
"""Module btclib.script."""
1212

1313
from btclib.script.script import Command, Script, op_int, parse, serialize
14-
from btclib.script.taproot import (
15-
TaprootScriptTree,
16-
check_output_pubkey,
17-
input_script_sig,
18-
output_prvkey,
19-
output_pubkey,
20-
)
21-
from btclib.script.witness import Witness
22-
23-
# hack to prevent circular import
24-
from btclib.script.script_pub_key import ( # isort:skip
14+
from btclib.script.script_pub_key import (
2515
ScriptPubKey,
2616
address,
2717
assert_nulldata,
@@ -41,7 +31,14 @@
4131
is_p2wsh,
4232
type_and_payload,
4333
)
44-
34+
from btclib.script.taproot import (
35+
TaprootScriptTree,
36+
check_output_pubkey,
37+
input_script_sig,
38+
output_prvkey,
39+
output_pubkey,
40+
)
41+
from btclib.script.witness import Witness
4542

4643
__all__ = [
4744
"Command",

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
project = "btclib"
2222
project_copyright = "2017-2023 The btclib developers"
2323
author = "The btclib developers"
24-
release = "2023.3"
24+
release = "2023.5.30"
2525

2626
# -- General configuration ---------------------------------------------------
2727
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

tests/script/test_script_pub_key.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,13 @@ def test_non_standard_script_in_p2wsh() -> None:
580580

581581
def test_p2tr() -> None:
582582
pub_key = "cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaf"
583-
payload = output_pubkey(pub_key)[0]
584-
script_pub_key = serialize(["OP_1", payload])
583+
out_pubkey = output_pubkey(pub_key)[0]
584+
script_pub_key = serialize(["OP_1", out_pubkey])
585585
assert_p2tr(script_pub_key)
586-
assert ("p2tr", payload) == type_and_payload(script_pub_key)
586+
assert ("p2tr", out_pubkey) == type_and_payload(script_pub_key)
587587

588588
network = "mainnet"
589-
addr = b32.p2tr(pub_key, network=network)
589+
addr = b32.p2tr(out_pubkey, network=network)
590590
assert addr == address(script_pub_key, network)
591591

592592
assert script_pub_key == ScriptPubKey.from_address(addr).script

tests/script/test_taproot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_bip_test_vector() -> None:
131131
script_tree = convert_script_tree(test["given"]["scriptTree"])
132132

133133
tweaked_pubkey = output_pubkey(f"02{pub_key}", script_tree)[0]
134-
address = b32.p2tr(f"02{pub_key}", script_tree)
134+
address = b32.p2tr(tweaked_pubkey)
135135

136136
assert tweaked_pubkey.hex() == test["intermediary"]["tweakedPubkey"]
137137
assert address == test["expected"]["bip350Address"]

tests/test_b32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test_p2wsh() -> None:
314314
def test_p2tr() -> None:
315315
key = 1
316316
pub_key = output_pubkey(key)[0]
317-
addr = b32.p2tr(key)
317+
addr = b32.p2tr(pub_key)
318318
_, wit_prg, _ = b32.witness_from_address(addr)
319319

320320
assert wit_prg == pub_key

0 commit comments

Comments
 (0)