I'd like to find every message attached to the transactions of an address So I have to search transaction by address with find_transactions(), then list all the signature_message_fragment How can I do this? I tried this:

list_add = [Address('MYADDRESS')] print(api.find_transactions(addresses = list_add))

and I get all the TXs hashes. Now how can I list all the signature_message_fragment?

  • Never used PyOTA, but there should be a GetTrytes or similar function which you pass in transaction hashes and get transaction trytes back. Then wrap that trytes into TransactionTrytes objects (or use substring parsing) to get the messages out. – mihi Mar 19 at 20:17

There's a utility function called find_transaction_objects (that will be added to the main API soon) that may be useful here.

It does the same thing as find_transactions, except it then converts the trytes that the IRI sends back into proper iota.transaction.base.Transaction objects.

Once you have Transaction objects, you can access each one's signature_message_fragment (which is an iota.types.TryteString object) and decode it:

from iota.commands.extended.utils import find_transaction_objects

transactions = find_transaction_objects(addresses=list_add)

for transaction in transactions:
  # Ignore input transactions; these have cryptographic signatures,
  # not human-readable messages.
  if transaction.value < 0:
    continue

  print(f'Message from {transaction.hash}:')

  message = transaction.signature_message_fragment
  if message is None:
    print('(None)')
  else:
    print(message.decode())

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.