@@ -216,9 +216,9 @@ def _to_proto(self):
216216 # We require the transaction to be frozen before converting to protobuf
217217 self ._require_frozen ()
218218
219- body_bytes = self ._transaction_body_bytes .get (self .node_account_id )
219+ body_bytes = self ._transaction_body_bytes .get (self ._node_account_id )
220220 if body_bytes is None :
221- raise ValueError (f"No transaction body found for node { self .node_account_id } " )
221+ raise ValueError (f"No transaction body found for node { self ._node_account_id } " )
222222
223223 # Get signature map, or create empty one if transaction is not signed
224224 sig_map = self ._signature_map .get (body_bytes )
@@ -245,7 +245,7 @@ def _resolve_transaction_id(self, client: Client):
245245 )
246246
247247 def _resolve_node_ids (self , client : Client ):
248- if self .node_account_id is None and len (self .node_account_ids ) == 0 and client is None :
248+ if self ._node_account_id is None and len (self .node_account_ids ) == 0 and client is None :
249249 raise ValueError (
250250 "Node account ID must be set before freezing. Use freeze_with(client) or manually set node_account_ids."
251251 )
@@ -297,27 +297,27 @@ def freeze_with(self, client: Client):
297297
298298 if self .batch_key :
299299 # For Inner Transaction of batch transaction node_account_id=0.0.0
300- self .node_account_id = AccountId (0 , 0 , 0 )
301- self ._transaction_body_bytes [AccountId (0 , 0 , 0 )] = self .build_transaction_body ().SerializeToString ()
302- return self
300+ self ._node_account_id = AccountId (0 , 0 , 0 )
301+ self .node_account_ids = [AccountId (0 , 0 , 0 )]
303302
304- # Single node
305- if self .node_account_id :
306- self .set_node_account_id (self .node_account_id )
307- self ._transaction_body_bytes [self .node_account_id ] = self .build_transaction_body ().SerializeToString ()
308- return self
303+ transaction_body = self .build_transaction_body ()
304+ transaction_body .transactionID .CopyFrom (self .transaction_id ._to_proto ())
305+ transaction_body .nodeAccountID .CopyFrom (self ._node_account_id ._to_proto ())
309306
310- # Multiple node
311- if len (self .node_account_ids ) > 0 :
312- for node_account_id in self .node_account_ids :
313- self .node_account_id = node_account_id
314- self ._transaction_body_bytes [node_account_id ] = self .build_transaction_body ().SerializeToString ()
307+ self ._transaction_body_bytes [AccountId (0 , 0 , 0 )] = transaction_body .SerializeToString ()
315308
316- else :
317- # Use all nodes from client network
318- for node in client .network .nodes :
319- self .node_account_id = node ._account_id
320- self ._transaction_body_bytes [node ._account_id ] = self .build_transaction_body ().SerializeToString ()
309+ # If nodes not set by user use all nodes from client network
310+ if len (self .node_account_ids ) == 0 :
311+ self .node_account_ids = [node ._account_id for node in client .network .nodes ]
312+
313+ for node_account_id in self .node_account_ids :
314+ self ._node_account_id = node_account_id
315+
316+ transaction_body = self .build_transaction_body ()
317+ transaction_body .transactionID .CopyFrom (self .transaction_id ._to_proto ())
318+ transaction_body .nodeAccountID .CopyFrom (node_account_id ._to_proto ())
319+
320+ self ._transaction_body_bytes [node_account_id ] = transaction_body .SerializeToString ()
321321
322322 return self
323323
@@ -405,7 +405,7 @@ def is_signed_by(self, public_key):
405405 """
406406 public_key_bytes = public_key .to_bytes_raw ()
407407
408- sig_map = self ._signature_map .get (self ._transaction_body_bytes .get (self .node_account_id ))
408+ sig_map = self ._signature_map .get (self ._transaction_body_bytes .get (self ._node_account_id ))
409409
410410 if sig_map is None :
411411 return False
@@ -452,20 +452,7 @@ def build_base_transaction_body(self) -> transaction_pb2.TransactionBody:
452452 Raises:
453453 ValueError: If required IDs are not set.
454454 """
455- if self .transaction_id is None :
456- if self .operator_account_id is None :
457- raise ValueError ("Operator account ID is not set." )
458- self .transaction_id = TransactionId .generate (self .operator_account_id )
459-
460- transaction_id_proto = self .transaction_id ._to_proto ()
461-
462- selected_node = self .node_account_id or (self .node_account_ids [0 ] if self .node_account_ids else None )
463- if selected_node is None :
464- raise ValueError ("Node account ID is not set." )
465-
466455 transaction_body = transaction_pb2 .TransactionBody ()
467- transaction_body .transactionID .CopyFrom (transaction_id_proto )
468- transaction_body .nodeAccountID .CopyFrom (selected_node ._to_proto ())
469456
470457 fee = self ._transaction_fee or self ._default_transaction_fee
471458 if hasattr (fee , "to_tinybars" ):
0 commit comments