Skip to content

Commit

Permalink
Merge pull request #171 from saratomaz/update_get_payment_vkey_hash
Browse files Browse the repository at this point in the history
update get_payment_vkey_hash to accept payment vkey as input
  • Loading branch information
mkoura committed Mar 27, 2023
2 parents 235356a + 8f387fc commit 614e5d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 12 additions & 5 deletions cardano_clusterlib/address_group.py
Expand Up @@ -110,20 +110,27 @@ def gen_payment_key_pair(

def get_payment_vkey_hash(
self,
payment_vkey_file: FileType,
payment_vkey_file: Optional[FileType] = None,
payment_vkey: Optional[str] = None,
) -> str:
"""Return the hash of an address key.
Args:
payment_vkey_file: A path to payment vkey file.
payment_vkey_file: A path to payment vkey file (optional).
payment_vkey: A payment vkey, (Bech32, optional).
Returns:
str: A generated hash.
"""
if payment_vkey:
cli_args = ["--payment-verification-key", payment_vkey]
elif payment_vkey_file:
cli_args = ["--payment-verification-key-file", str(payment_vkey_file)]
else:
raise AssertionError("Either `payment_vkey` or `payment_vkey_file` is needed.")

return (
self._clusterlib_obj.cli(
["address", "key-hash", "--payment-verification-key-file", str(payment_vkey_file)]
)
self._clusterlib_obj.cli(["address", "key-hash", *cli_args])
.stdout.rstrip()
.decode("ascii")
)
Expand Down
7 changes: 6 additions & 1 deletion cardano_clusterlib/transaction_group.py
Expand Up @@ -1245,7 +1245,12 @@ def build_multisig_script(
out_file = destination_dir / f"{script_name}_multisig.script"

scripts_l: List[dict] = [
{"keyHash": self._clusterlib_obj.g_address.get_payment_vkey_hash(f), "type": "sig"}
{
"keyHash": self._clusterlib_obj.g_address.get_payment_vkey_hash(
payment_vkey_file=f
),
"type": "sig",
}
for f in payment_vkey_files
]
if slot:
Expand Down

0 comments on commit 614e5d6

Please sign in to comment.