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

bundle.get_messages Returns Wrong Messages for ProposedBundle #257

Open
lzpap opened this issue Nov 1, 2019 · 0 comments
Open

bundle.get_messages Returns Wrong Messages for ProposedBundle #257

lzpap opened this issue Nov 1, 2019 · 0 comments
Labels

Comments

@lzpap
Copy link
Member

lzpap commented Nov 1, 2019

Description

Calling get_messages on a ProposedBundle object returns only the message of the first transaction in the bundle.

Analysis

get_messages relies on group_transactions to iterate over transactions in the bundle.
group_transactions uses self.transactions list, that does not exist for ProposedBundle objects, it is created in Bundle.__init__(). Instead, ProposedBundle uses _transactions list to keep track of its transactions.

Discussion

Can we extend get_messages to work on ProposedBundles as well?
Why the different naming of transactions and _transactions lists?

Reproduce

from iota import Address, ProposedBundle, \
    ProposedTransaction, TryteString, Bundle

transactions = [
    ProposedTransaction(
        address = Address.from_unicode('FIRSTDUMMYADDRESS'),
        message= TryteString.from_unicode('First message.'),
        value = 0,
    ),
    ProposedTransaction(
        address = Address.from_unicode('SECONDDUMMYADDRESS'),
        message= TryteString.from_unicode('Second message.'),
        value = 0,
    ),
    ProposedTransaction(
        address = Address.from_unicode('THIRDDUMMYADDRESS'),
        message= TryteString.from_unicode('Third message.'),
        value = 0,
    ),
]

bundle = ProposedBundle(transactions)

# signature_message_fragment fields are empty until we finalize the bundle.
# get_messages gathers these so we need to finalize first.
bundle.finalize()

# Doesn't work
message = bundle.get_messages()
# Contains only first message
print(message)

# Reconstructing the bundle from trytes, then work!
tryte_constructed_bundle = \
    Bundle.from_tryte_strings(bundle.as_tryte_strings())
message = tryte_constructed_bundle.get_messages()
print(message)
@lzpap lzpap added the bug label Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant