@@ -226,7 +226,28 @@ def _to_proto(self):
226226
227227 signed_transaction = transaction_contents_pb2 .SignedTransaction (bodyBytes = body_bytes , sigMap = sig_map )
228228
229- return transaction_pb2 .Transaction (signedTransactionBytes = signed_transaction .SerializeToString ())
229+
230+ return transaction_pb2 .Transaction (
231+ signedTransactionBytes = signed_transaction .SerializeToString ()
232+ )
233+
234+ def _resolve_transaction_id (self , client : "Client" ):
235+ if self .transaction_id is not None :
236+ return
237+
238+ if client is not None :
239+ operator_account_id = client .operator_account_id
240+ if operator_account_id is not None :
241+ self .transaction_id = client .generate_transaction_id ()
242+ else :
243+ raise ValueError (
244+ "Client must have an operator_account or transactionId must be set."
245+ )
246+ else :
247+ raise ValueError (
248+ "Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
249+ )
250+
230251
231252 def freeze (self ):
232253 """
@@ -266,19 +287,7 @@ def freeze_with(self, client: "Client"):
266287
267288
268289 # Check transaction_id and node id to be set when using freeze()
269- if self .transaction_id is None :
270- if client is not None :
271- operator_account_id = client .operator_account_id
272- if operator_account_id is not None :
273- self .transaction_id = client .generate_transaction_id ()
274- else :
275- raise ValueError (
276- "Client must have an operator_account or transactionId must be set."
277- )
278- else :
279- raise ValueError (
280- "Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
281- )
290+ self ._resolve_transaction_id (client )
282291
283292
284293 if self .node_account_id is None and len (self .node_account_ids ) == 0 :
0 commit comments