diff --git a/cmd/kaspawallet/broadcast.go b/cmd/kaspawallet/broadcast.go index c25a580f5..7eb3f421f 100644 --- a/cmd/kaspawallet/broadcast.go +++ b/cmd/kaspawallet/broadcast.go @@ -42,14 +42,29 @@ func broadcast(conf *broadcastConfig) error { return err } - response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: transactions}) - if err != nil { - return err - } - fmt.Println("Transactions were sent successfully") - fmt.Println("Transaction ID(s): ") - for _, txID := range response.TxIDs { - fmt.Printf("\t%s\n", txID) + const batch = 50 + position := 0 + + // We send in batches to avoid communication errors + for position < len(transactions) { + var transactionBatch [][]byte + if position+batch > len(transactions) { + transactionBatch = transactions[position:] + } else { + transactionBatch = transactions[position : position+batch] + } + response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: transactionBatch}) + if err != nil { + return err + } + if position == 0 { + fmt.Println("Transactions were sent successfully") + } + fmt.Println("Transaction ID(s): ") + for _, txID := range response.TxIDs { + fmt.Printf("\t%s\n", txID) + } + position += batch } return nil