From 025ce99ff1595ed3c0476827b3cf5a3e4585517e Mon Sep 17 00:00:00 2001 From: Harley Lang Date: Wed, 5 Sep 2018 12:52:53 -0700 Subject: [PATCH] Create decode_bundle_messages.py --- examples/decode_bundle_messages.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/decode_bundle_messages.py diff --git a/examples/decode_bundle_messages.py b/examples/decode_bundle_messages.py new file mode 100644 index 0000000..6e42562 --- /dev/null +++ b/examples/decode_bundle_messages.py @@ -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()