Skip to content

Commit

Permalink
Update to v0.3.2 (#8)
Browse files Browse the repository at this point in the history
* upgrade: update from cryptogarageinc/v0.3.7
  • Loading branch information
ko-matsu authored Sep 27, 2021
1 parent 6aa25a9 commit 0e27006
Show file tree
Hide file tree
Showing 42 changed files with 2,283 additions and 331 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check_pre-merge_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
push:
branches:
- master
- stable_v*
paths-ignore:
- '.github/workflows/create_release-and-upload.yml'
- '.github/workflows/code_scanner.yml'
- 'README.md'
pull_request:
branches:
- master
- stable_v*

env:
GITHUB_VERSION: v0.0.10
Expand Down
35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ report_html = "coverage html"
report_xml = "coverage xml"
format = "autopep8 --aggressive --aggressive -ir setup.py cfd tests"
format_detail = "autopep8 --aggressive --aggressive -ivr setup.py cfd tests"
format_check = "autopep8 -d -r setup.py src"
format_check = "autopep8 -d -r setup.py cfd"
lint = "flake8 --show-source setup.py cfd tests"
cleanup = "python ./tools/cleanup.py cmake_build"
build = "python ./setup.py build"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ pip install --user .

### install from wheel

1. get releases asset. (ex. https://github.com/p2pderivatives/cfd-python/releases/download/v0.3.0/cfd-0.3.0-py3-none-win_amd64.whl )
1. get releases asset. (ex. https://github.com/p2pderivatives/cfd-python/releases/download/v0.3.2/cfd-0.3.2-py3-none-win_amd64.whl )
2. install pip
```
pip install --user cfd-0.3.0-py3-none-win_amd64.whl
pip install --user cfd-0.3.2-py3-none-win_amd64.whl
```

### uninstall
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.3.2
3 changes: 2 additions & 1 deletion cfd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import glob

__version__ = '0.1.0'
__version__ = '0.3.0'

__all__ = [
os.path.split(os.path.splitext(file)[0])[1]
Expand All @@ -10,6 +10,7 @@
]
"""
'address',
'block',
'confidential_address',
'confidential_transaction',
'crypto',
Expand Down
45 changes: 41 additions & 4 deletions cfd/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .util import get_util, CfdError, JobHandle, to_hex_string
from .key import Network, Pubkey, SchnorrPubkey
from .script import HashType, Script
from .taproot import TaprootScriptTree
from .taproot import TaprootScriptTree, TapBranch


##
Expand Down Expand Up @@ -49,7 +49,8 @@ class Address:
##
# @var taproot_script_tree
# Taproot script tree.
taproot_script_tree: Optional['TaprootScriptTree'] = None
taproot_script_tree: Optional[Union['TaprootScriptTree',
'TapBranch']] = None

##
# @brief constructor.
Expand Down Expand Up @@ -204,9 +205,11 @@ def p2sh_p2wsh(cls, redeem_script, network=Network.MAINNET) -> 'Address':
# @return address object.
@classmethod
def taproot(
cls, pubkey: Union['SchnorrPubkey', 'TaprootScriptTree'],
cls, pubkey: Union[
'SchnorrPubkey', 'TaprootScriptTree'],
network=Network.MAINNET,
script_tree: Optional['TaprootScriptTree'] = None) -> 'Address':
script_tree: Optional[Union[
'TaprootScriptTree', 'TapBranch']] = None) -> 'Address':
if isinstance(pubkey, TaprootScriptTree):
pk, _, _, _ = pubkey.get_taproot_data()
addr = cls.from_pubkey_hash(pk, HashType.TAPROOT, network)
Expand All @@ -217,6 +220,11 @@ def taproot(
addr = cls.from_pubkey_hash(pk, HashType.TAPROOT, network)
addr.taproot_script_tree = script_tree
return addr
elif isinstance(script_tree, TapBranch):
pk, _, _, _ = script_tree.get_taproot_data(pubkey)
addr = cls.from_pubkey_hash(pk, HashType.TAPROOT, network)
addr.taproot_script_tree = script_tree
return addr
else:
return cls.from_pubkey_hash(pubkey, HashType.TAPROOT, network)

Expand Down Expand Up @@ -426,6 +434,35 @@ def get_pegin_address(
return cls.parse(addr), Script(claim_script), Script(
tweaked_fedpeg)

##
# @brief get pegout address.
# @param[in] descriptor output descriptor or xpub
# @param[in] bip32_counter bip32 counter
# @param[in] hash_type script hash type
# @param[in] mainchain_network mainchain network type
# @param[in] elements_network elements network type
# @retval [0] pegout address.
# @retval [1] base descriptor.
@classmethod
def get_pegout_address(
cls,
descriptor: str,
bip32_counter=0,
hash_type: Union['HashType', str] = HashType.P2PKH,
mainchain_network=Network.MAINNET,
elements_network=Network.LIQUID_V1,
) -> Tuple['Address', str]:
_hash_type = HashType.get(hash_type)
_network = Network.get(mainchain_network)
_elements_network = Network.get(elements_network)
util = get_util()
with util.create_handle() as handle:
addr, base_descriptor = util.call_func(
'CfdGetPegoutAddress',
handle.get_handle(), _network.value, _elements_network.value,
str(descriptor), int(bip32_counter), _hash_type.value)
return cls.parse(addr), base_descriptor


##
# All import target.
Expand Down
Loading

0 comments on commit 0e27006

Please sign in to comment.