Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions blockfrost/api/cardano/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,27 @@ def transaction_redeemers(self, hash: str, **kwargs):
headers=self.default_headers
)

@list_request_wrapper
def transaction_required_signers(self, hash: str, **kwargs):
"""
Obtain the transaction required signers (extra transaction witnesses).

https://docs.blockfrost.io/#tag/Cardano-Transactions/paths/~1txs~1{hash}~required_signers/get

:param hash: Hash of the requested transaction.
:type hash: str
:param return_type: Optional. "object", "json" or "pandas". Default: "object".
:type return_type: str
:returns A list of objects.
:rtype [Namespace]
:raises ApiError: If API fails
:raises Exception: If the API response is somehow malformed.
"""
return requests.get(
url=f"{self.url}/txs/{hash}/required_signers",
headers=self.default_headers
)


@request_wrapper
def transaction_submit(self, file_path: str, **kwargs):
Expand Down
22 changes: 22 additions & 0 deletions tests/test_cardano_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,28 @@ def test_integration_transaction_redeemers():
assert api.transaction_redeemers(hash=hash) == []


def test_transaction_required_signers(requests_mock):
api = BlockFrostApi()
mock_data = [
{
{
"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f',
},
}
]
requests_mock.get(f"{api.url}/txs/{hash}/required_signers", json=mock_data)
assert api.transaction_required_signers(
hash=hash) == convert_json_to_object(mock_data)


def test_integration_transaction_required_signers():
if os.getenv('BLOCKFROST_PROJECT_ID_MAINNET'):
api = BlockFrostApi(project_id=os.getenv(
'BLOCKFROST_PROJECT_ID_MAINNET'))
assert api.transaction_required_signers(hash="b024ad35c6309a71a8e613d8bfea2a8185d81eda379ca9128877adefcde1c515") == [
{"witness_hash": 'db7685e2d763133630e1a4afdefc5752d4b1c9be6c102e71242fb06f'}]


def test_transaction_submit(requests_mock):
api = BlockFrostApi()
mock_data = hash
Expand Down