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

bundle.get_messages Returns Wrong Messages for ProposedBundle #257

Open
@lzpap

Description

@lzpap

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions