Skip to content

Commit

Permalink
Combine all reference Tx inputs in TxRawOutput data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoura committed Jun 13, 2023
1 parent 3c685b7 commit 3512f52
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions cardano_clusterlib/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class TxRawOutput(NamedTuple):
required_signers: OptionalFiles = () # Signing keys that are required for the transaction
# Hashes of signing keys that are required for the transaction
required_signer_hashes: Union[List[str], Tuple[()]] = ()
combined_reference_txins: OptionalUTXOData = () # All reference tx inputs


class PoolCreationOutput(NamedTuple):
Expand Down
14 changes: 14 additions & 0 deletions cardano_clusterlib/transaction_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ def build_raw_tx_bare(
script_valid=script_valid,
required_signers=required_signers,
required_signer_hashes=required_signer_hashes,
combined_reference_txins=txtools._get_reference_txins(
readonly_reference_txins=readonly_reference_txins,
script_txins=script_txins,
mint=mint,
complex_certs=complex_certs,
script_withdrawals=script_withdrawals,
),
)

def build_raw_tx(
Expand Down Expand Up @@ -913,6 +920,13 @@ def build_tx( # noqa: C901
script_valid=script_valid,
required_signers=required_signers,
required_signer_hashes=required_signer_hashes,
combined_reference_txins=txtools._get_reference_txins(
readonly_reference_txins=readonly_reference_txins,
script_txins=script_txins,
mint=mint,
complex_certs=complex_certs,
script_withdrawals=script_withdrawals,
),
)

def sign_tx(
Expand Down
22 changes: 22 additions & 0 deletions cardano_clusterlib/txtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,28 @@ def _get_withdrawals(
return withdrawals, script_withdrawals, withdrawals_txouts


def _get_reference_txins(
readonly_reference_txins: structs.OptionalUTXOData,
script_txins: structs.OptionalScriptTxIn,
mint: structs.OptionalMint,
complex_certs: structs.OptionalScriptCerts,
script_withdrawals: structs.OptionalScriptWithdrawals,
) -> List[structs.UTXOData]:
"""Get list of reference txins."""
script_ref_txins = [
r.reference_txin
for r in (
*script_txins,
*mint,
*complex_certs,
*script_withdrawals,
)
if r.reference_txin
]

return [*readonly_reference_txins, *script_ref_txins]


def _get_txin_strings(
txins: structs.OptionalUTXOData, script_txins: structs.OptionalScriptTxIn
) -> Set[str]:
Expand Down

0 comments on commit 3512f52

Please sign in to comment.