1111from iota .crypto .signing import KeyGenerator
1212from iota .crypto .types import PrivateKey
1313from iota .exceptions import with_context
14- from iota .json import JsonSerializable
15- from iota .transaction .base import Transaction
16- from iota .transaction .types import Fragment , TransactionHash
14+ from iota .transaction .base import Bundle , Transaction
15+ from iota .transaction .types import BundleHash , Fragment , TransactionHash
1716from iota .transaction .utils import get_current_timestamp
1817from iota .types import Address , Hash , Tag , TryteString
1918
@@ -80,7 +79,7 @@ def as_tryte_string(self):
8079 return super (ProposedTransaction , self ).as_tryte_string ()
8180
8281
83- class ProposedBundle (JsonSerializable , Sequence [ProposedTransaction ]):
82+ class ProposedBundle (Bundle , Sequence [ProposedTransaction ]):
8483 """
8584 A collection of proposed transactions, to be treated as an atomic
8685 unit when attached to the Tangle.
@@ -89,8 +88,6 @@ def __init__(self, transactions=None, inputs=None, change_address=None):
8988 # type: (Optional[Iterable[ProposedTransaction]], Optional[Iterable[Address]], Optional[Address]) -> None
9089 super (ProposedBundle , self ).__init__ ()
9190
92- self .hash = None # type: Optional[Hash]
93-
9491 self ._transactions = [] # type: List[ProposedTransaction]
9592
9693 if transactions :
@@ -177,17 +174,6 @@ def as_json_compatible(self):
177174 """
178175 return [txn .as_json_compatible () for txn in self ]
179176
180- def as_tryte_strings (self ):
181- # type: () -> List[TryteString]
182- """
183- Returns the bundle as a list of TryteStrings, suitable as inputs
184- for :py:meth:`iota.api.Iota.send_trytes`.
185- """
186- # Return the transaction trytes in reverse order, so that the tail
187- # transaction is last. This will allow the node to link the
188- # transactions properly when it performs PoW.
189- return [t .as_tryte_string () for t in reversed (self )]
190-
191177 def add_transaction (self , transaction ):
192178 # type: (ProposedTransaction) -> None
193179 """
@@ -333,13 +319,13 @@ def finalize(self):
333319
334320 sponge .absorb (txn .get_signature_validation_trytes ().as_trits ())
335321
336- bundle_hash = [0 ] * HASH_LENGTH # type: MutableSequence[int]
337- sponge .squeeze (bundle_hash )
338- self .hash = Hash .from_trits (bundle_hash )
322+ bundle_hash_trits = [0 ] * HASH_LENGTH # type: MutableSequence[int]
323+ sponge .squeeze (bundle_hash_trits )
339324
340325 # Copy bundle hash to individual transactions.
326+ bundle_hash = BundleHash .from_trits (bundle_hash_trits )
341327 for txn in self :
342- txn .bundle_hash = self . hash
328+ txn .bundle_hash = bundle_hash
343329
344330 # Initialize signature/message fragment.
345331 txn .signature_message_fragment = Fragment (txn .message or b'' )
0 commit comments