Skip to content

Commit

Permalink
[UPD] Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mccwdev committed Oct 13, 2023
1 parent 33c2ed7 commit b55529e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
17 changes: 16 additions & 1 deletion bitcoinlib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,23 @@ def get_encoding_from_witness(witness_type=None):


def get_key_structure_data(witness_type, multisig=False, purpose=None, encoding=None):
"""
Get data from wallet key structure. Provide witness_type and multisig to determine key path, purpose (BIP44
reference) and encoding.
:param witness_type: Witness type used for transaction validation
:type witness_type: str
:param multisig: Multisig or single keys wallet, default is False: single key / 1-of-1 wallet
:type multisig: bool
:param purpose: Overrule purpose found in wallet structure. Do not use unless you known what you are doing.
:type purpose: int
:param encoding: Overrule encoding found in wallet structure. Do not use unless you known what you are doing.
:type encoding: str
:return: (key_path, purpose, encoding)
"""
if not witness_type:
return None, None, None
return None, purpose, encoding
ks = [k for k in WALLET_KEY_STRUCTURES if
k['witness_type'] == witness_type and k['multisig'] == multisig and k['purpose'] is not None]
if len(ks) > 1:
Expand Down
12 changes: 2 additions & 10 deletions bitcoinlib/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,16 +1263,6 @@ def create(cls, name, keys=None, owner='', network=None, account_id=0, purpose=0
key_path = ['m']
purpose = 0
else:
# ks = [k for k in WALLET_KEY_STRUCTURES if k['witness_type'] == witness_type and
# k['multisig'] == multisig and k['purpose'] is not None]
# if len(ks) > 1:
# raise WalletError("Please check definitions in WALLET_KEY_STRUCTURES. Multiple options found for "
# "witness_type - multisig combination")
# if ks and not purpose:
# purpose = ks[0]['purpose']
# if ks and not encoding:
# encoding = ks[0]['encoding']
# key_path = ks[0]['key_path']
key_path, purpose, encoding = get_key_structure_data(witness_type, multisig, purpose, encoding)
else:
if purpose is None:
Expand Down Expand Up @@ -2132,6 +2122,8 @@ def key_for_path(self, path, level_offset=None, name=None, account_id=None, cosi
:type address_index: int
:param change: Change key = 1 or normal = 0, normally provided to 'path' argument
:type change: int
:param witness_type: Use to create key with different witness_type
:type witness_type: str
:param network: Network name. Leave empty for default network
:type network: str
:param recreate: Recreate key, even if already found in wallet. Can be used to update public key with private key info
Expand Down

0 comments on commit b55529e

Please sign in to comment.