Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Create decode_bundle_messages.py #205

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions examples/decode_bundle_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from iota import Iota
from iota import TryteString
from iota.commands.extended.utils import get_bundles_from_transaction_hashes as goget

# declare node; change as you see fit
api = Iota('https://nodes.thetangle.org:443')

# this MWE assumes that you already have you already have a bundle hash; one is declared here as an example
bundle_hash = [TryteString('YXPOLGAAEWVBCHH9CGOPNJXE9HQHHLJFTDQKKLHFGOHOWKZQGHOQVZSCVIRKDEJVGDQPT99WOZHVCUYDC')]

# return all transactions in the bundle
bundle_transactions = api.find_transactions( bundles = bundle_hash )['hashes']

# return transaction objects for each tranaction in bundle
transaction_objs = vars(goget(api.adapter,bundle_transactions,False)[0])['transactions']

# string together message across transactions
message = ''
for t in transaction_objs:
message = message + str(vars(t)['signature_message_fragment'])

# print message decoded:
print TryteString(message).decode()