@@ -233,7 +233,8 @@ func (t *Txm) broadcastLoop() {
233233 }
234234}
235235
236- // Attempts to broadcast a transaction with retries on failure.
236+ // broadcastWithRetry Attempts to broadcast a transaction with retries on failure. We only retry if there was a
237+ // failure to send the transaction, not if the transaction was broadcast but failed to execute (non-zero exit code).
237238func (t * Txm ) broadcastWithRetry (ctx context.Context , tx * Tx , msg * wallet.Message , txID string ) error {
238239 var receivedMessage * tracetracking.ReceivedMessage
239240 var err error
@@ -244,7 +245,7 @@ func (t *Txm) broadcastWithRetry(ctx context.Context, tx *Tx, msg *wallet.Messag
244245 return fmt .Errorf ("failed to get client: %w" , cerr )
245246 }
246247
247- // try to send transaction
248+ // try to broadcast transaction
248249 for attempt := uint (1 ); attempt <= t .config .MaxSendRetryAttempts ; attempt ++ {
249250 t .logger .Debugw ("sending transaction to TON" ,
250251 "txID" , txID ,
@@ -254,16 +255,18 @@ func (t *Txm) broadcastWithRetry(ctx context.Context, tx *Tx, msg *wallet.Messag
254255 "bounce" , msg .InternalMessage .Bounce ,
255256 "hasBody" , msg .InternalMessage .Body != nil )
256257 receivedMessage , _ , err = client .SendWaitTransaction (ctx , tx .To , msg )
257-
258- if receivedMessage .ExitCode != 0 {
259- t .logger .Errorw ("transaction failed" , "exitcode" , receivedMessage .ExitCode , "description" , receivedMessage .ExitCode .Describe ())
260- }
261-
262258 if err == nil {
263259 t .logger .Infow ("transaction broadcasted" ,
264260 "txID" , txID ,
265261 "to" , tx .To .String (),
266262 "amount" , tx .Amount .Nano ().String ())
263+
264+ // Transaction was broadcast successfully, but ultimately failed to execute due to ExitCode.
265+ if receivedMessage .ExitCode != 0 {
266+ t .logger .Errorw ("transaction failed" , "exitcode" , receivedMessage .ExitCode , "description" , receivedMessage .ExitCode .Describe ())
267+ }
268+
269+ // Wait for and gather full trace regardless of exit code for debugging purposes
267270 err = receivedMessage .WaitForTrace (ctx , client .Client )
268271 if err != nil {
269272 t .logger .Errorw ("failed to wait for trace" , "error" , err )
@@ -273,6 +276,7 @@ func (t *Txm) broadcastWithRetry(ctx context.Context, tx *Tx, msg *wallet.Messag
273276 break
274277 }
275278
279+ // Transaction failed to broadcast. Log error as a warning for now and fall through to retry delay below.
276280 t .logger .Warnw ("failed to broadcast tx, will retry" ,
277281 "txID" , txID ,
278282 "attempt" , attempt ,
0 commit comments